You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: doc/source/io.rst
+40-3
Original file line number
Diff line number
Diff line change
@@ -1648,7 +1648,7 @@ with optional parameters:
1648
1648
1649
1649
DataFrame
1650
1650
- default is ``columns``
1651
-
- allowed values are {``split``, ``records``, ``index``, ``columns``, ``values``}
1651
+
- allowed values are {``split``, ``records``, ``index``, ``columns``, ``values``, ``table``}
1652
1652
1653
1653
The format of the JSON string
1654
1654
@@ -1732,6 +1732,9 @@ values, index and columns. Name is also included for ``Series``:
1732
1732
dfjo.to_json(orient="split")
1733
1733
sjo.to_json(orient="split")
1734
1734
1735
+
**Table oriented** serializes to the JSON `Table Schema`_, allowing for the
1736
+
preservation of metadata including but not limited to dtypes and index names.
1737
+
1735
1738
.. note::
1736
1739
1737
1740
Any orient option that encodes to a JSON object will not preserve the ordering of
@@ -1833,7 +1836,7 @@ is ``None``. To explicitly force ``Series`` parsing, pass ``typ=series``
1833
1836
1834
1837
DataFrame
1835
1838
- default is ``columns``
1836
-
- allowed values are {``split``, ``records``, ``index``, ``columns``, ``values``}
1839
+
- allowed values are {``split``, ``records``, ``index``, ``columns``, ``values``, ``table``}
1837
1840
1838
1841
The format of the JSON string
1839
1842
@@ -1846,6 +1849,8 @@ is ``None``. To explicitly force ``Series`` parsing, pass ``typ=series``
1846
1849
``index``; dict like {index -> {column -> value}}
1847
1850
``columns``; dict like {column -> {index -> value}}
1848
1851
``values``; just the values array
1852
+
``table``; adhering to the JSON `Table Schema`_
1853
+
1849
1854
1850
1855
- ``dtype`` : if True, infer dtypes, if a dict of column to dtype, then use those, if False, then don't infer dtypes at all, default is True, apply only to the data
1851
1856
- ``convert_axes`` : boolean, try to convert the axes to the proper dtypes, default is True
@@ -2202,7 +2207,39 @@ A few notes on the generated table schema:
A ``DataFrame`` can now be written to and subsequently read back via JSON while preserving metadata through usage of the ``orient='table'`` argument (see :issue:`18912` and :issue:`9146`). Previously, none of the available ``orient`` values guaranteed the preservation of dtypes and index names, amongst other metadata.
Please note that the string `index` is not supported with the round trip format, as it is used by default in ``write_json`` to indicate a missing index name.
0 commit comments