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/whatsnew/v0.23.0.rst
+48-12Lines changed: 48 additions & 12 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -50,19 +50,55 @@ JSON read/write round-trippable with ``orient='table'``
50
50
51
51
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.
In [5]: new_df = pd.read_json('test.json', orient='table')
83
+
84
+
In [6]: new_df
85
+
Out[6]:
86
+
foo bar baz qux
87
+
idx
88
+
0 1 a 2018-01-01 a
89
+
1 2 b 2018-01-02 b
90
+
2 3 c 2018-01-03 c
91
+
3 4 d 2018-01-04 c
92
+
93
+
[4 rows x 4 columns]
94
+
95
+
In [7]: new_df.dtypes
96
+
Out[7]:
97
+
foo int64
98
+
bar object
99
+
baz datetime64[ns]
100
+
qux category
101
+
Length: 4, dtype: object
66
102
67
103
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