Skip to content

DOC: Add example using dtype_backend="numpy_nullable" to read_json #56561

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
Dec 19, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 13 additions & 0 deletions pandas/io/json/_json.py
Original file line number Diff line number Diff line change
Expand Up @@ -763,6 +763,19 @@ def read_json(
{{"index":"row 2","col 1":"c","col 2":"d"}}]\
}}\
'

The following example uses ``dtype_backend="numpy_nullable"``

>>> data = '''{{"index": {{"0": 0, "1": 1}},
... "a": {{"0": 1, "1": null}},
... "b": {{"0": 2.5, "1": 4.5}},
... "c": {{"0": true, "1": false}},
... "d": {{"0": "a", "1": "b"}},
... "e": {{"0": 1577.2, "1": 1577.1}}}}'''
>>> pd.read_json(StringIO(data), dtype_backend="numpy_nullable")
index a b c d e
0 0 1 2.5 True a 1577.2
1 1 <NA> 4.5 False b 1577.1
"""
if orient == "table" and dtype:
raise ValueError("cannot pass both dtype and orient='table'")
Expand Down