Skip to content
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

DOC: Add example with numpy_nullable to pd.read_json() #56473

Closed
wants to merge 17 commits into from
15 changes: 15 additions & 0 deletions pandas/io/json/_json.py
Original file line number Diff line number Diff line change
Expand Up @@ -763,6 +763,21 @@ def read_json(
{{"index":"row 2","col 1":"c","col 2":"d"}}]\
}}\
'

The follwing 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}}'
>>> df = pd.read_json(data, dtype_backend="numpy_nullable")
linus-md marked this conversation as resolved.
Show resolved Hide resolved
>>> print(df)
index a b c d e
0 0 1 2.5 True a 1577.2
1 1 <NA> 4.5 False b 1577.1

linus-md marked this conversation as resolved.
Show resolved Hide resolved
"""
if orient == "table" and dtype:
raise ValueError("cannot pass both dtype and orient='table'")
Expand Down
Loading