Skip to content

DOC: Adding examples for dtype_backend="pyarrow" for read_json() #52813

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Apr 21, 2023

Conversation

Dharni0607
Copy link
Contributor

Added an example for dtype_backend="pyarrow" for read_json()

@Dharni0607
Copy link
Contributor Author

@rhshadrach rhshadrach added Docs IO JSON read_json, to_json, json_normalize Arrow pyarrow functionality labels Apr 21, 2023
'"e":{"0":null,"1":6.0},"f":{"0":null,"1":7.5},"g":{"0":null,"1":true},"h":{"0":null,"1":"a"},'
'"i":{"0":"12-31-2019","1":"12-31-2019"},"j":{"0":null,"1":null}}'
)
pd.read_json(StringIO(data), dtype_backend="pyarrow")
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you do

df = pd.read_json(StringIO(data), dtype_backend="pyarrow")
df
df.dtypes

?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Added

@phofl phofl added the Sprints Sprint Pull Requests label Apr 21, 2023
Comment on lines 1001 to 1002
import io
data = io.StringIO("date\n12 Jan 2000\n2000-01-13\n")
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
import io
data = io.StringIO("date\n12 Jan 2000\n2000-01-13\n")
data = StringIO("date\n12 Jan 2000\n2000-01-13\n")

It seems that all other examples use StringIO(..) instead of io.StringIO(..), the the StringIO object itself was already imported. So this should fix the error as well.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There is one other usage of io.StringIO a few lines below that would need to be updated as well (but I can't comment on that line)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, removed the import and it fixed the error

@phofl phofl added this to the 2.1 milestone Apr 21, 2023
@phofl phofl merged commit e1452b7 into pandas-dev:main Apr 21, 2023
@phofl
Copy link
Member

phofl commented Apr 21, 2023

thx @Dharni0607

@jorisvandenbossche
Copy link
Member

Thanks again Dharani!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Arrow pyarrow functionality Docs IO JSON read_json, to_json, json_normalize Sprints Sprint Pull Requests
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants