Skip to content

Commit 99e6897

Browse files
linus-mdmroeschke
andauthored
DOC: Add example using dtype_backend="numpy_nullable" to read_json (#56561)
* DOC: Add example using ``dtype_backend="numpy_nullable"`` to ``read_json()`` * Update pandas/io/json/_json.py Co-authored-by: Matthew Roeschke <[email protected]> --------- Co-authored-by: Matthew Roeschke <[email protected]>
1 parent 6787245 commit 99e6897

File tree

1 file changed

+13
-0
lines changed

1 file changed

+13
-0
lines changed

pandas/io/json/_json.py

+13
Original file line numberDiff line numberDiff line change
@@ -757,6 +757,19 @@ def read_json(
757757
{{"index":"row 2","col 1":"c","col 2":"d"}}]\
758758
}}\
759759
'
760+
761+
The following example uses ``dtype_backend="numpy_nullable"``
762+
763+
>>> data = '''{{"index": {{"0": 0, "1": 1}},
764+
... "a": {{"0": 1, "1": null}},
765+
... "b": {{"0": 2.5, "1": 4.5}},
766+
... "c": {{"0": true, "1": false}},
767+
... "d": {{"0": "a", "1": "b"}},
768+
... "e": {{"0": 1577.2, "1": 1577.1}}}}'''
769+
>>> pd.read_json(StringIO(data), dtype_backend="numpy_nullable")
770+
index a b c d e
771+
0 0 1 2.5 True a 1577.2
772+
1 1 <NA> 4.5 False b 1577.1
760773
"""
761774
if orient == "table" and dtype:
762775
raise ValueError("cannot pass both dtype and orient='table'")

0 commit comments

Comments
 (0)