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
+50-10Lines changed: 50 additions & 10 deletions
Original file line number
Diff line number
Diff line change
@@ -1034,11 +1034,12 @@ with optional parameters:
1034
1034
``columns``; dict like {column -> {index -> value}}
1035
1035
``values``; just the values array
1036
1036
1037
-
- ``date_format`` : type of date conversion (epoch = epoch milliseconds, iso = ISO8601), default is epoch
1037
+
- ``date_format`` : string, type of date conversion, 'epoch' for timestamp, 'iso' for ISO8601.
1038
1038
- ``double_precision`` : The number of decimal places to use when encoding floating point values, default 10.
1039
1039
- ``force_ascii`` : force encoded string to be ASCII, default True.
1040
+
- ``date_unit`` : The time unit to encode to, governs timestamp and ISO8601 precision. One of 's', 'ms', 'us' or 'ns' for seconds, milliseconds, microseconds and nanoseconds respectively. Default 'ms'.
1040
1041
1041
-
Note NaN'sand None will be converted to null and datetime objects will be converted based on the date_format parameter
1042
+
Note NaN's, NaT's and None will be converted to null and datetime objects will be converted based on the date_format and date_unit parameters.
Writing to a file, with a date index and a date column
1059
1074
1060
1075
.. ipython:: python
@@ -1063,7 +1078,7 @@ Writing to a file, with a date index and a date column
1063
1078
dfj2['date'] = Timestamp('20130101')
1064
1079
dfj2['ints'] =list(range(5))
1065
1080
dfj2['bools'] =True
1066
-
dfj2.index = date_range('20130101',periods=5)
1081
+
dfj2.index = date_range('20130101',periods=5)
1067
1082
dfj2.to_json('test.json')
1068
1083
open('test.json').read()
1069
1084
@@ -1107,16 +1122,22 @@ is ``None``. To explicity force ``Series`` parsing, pass ``typ=series``
1107
1122
- ``keep_default_dates`` : boolean, default True. If parsing dates, then parse the default datelike columns
1108
1123
- ``numpy`` : direct decoding to numpy arrays. default is False;
1109
1124
Note that the JSON ordering **MUST** be the same for each term if ``numpy=True``
1110
-
- ``precise_float`` : boolean, default ``False``. Set to enable usage of higher precision (strtod) function
1111
-
when decoding string to double values. Default (``False``) is to use fast but less precise builtin functionality
1125
+
- ``precise_float`` : boolean, default ``False``. Set to enable usage of higher precision (strtod) function when decoding string to double values. Default (``False``) is to use fast but less precise builtin functionality
1126
+
- ``date_unit`` : string, the timestamp unit to detect if converting dates. Default
1127
+
None. By default the timestamp precision will be detected, if this is not desired
1128
+
then pass one of 's', 'ms', 'us' or 'ns' to force timestamp precision to
1129
+
seconds, milliseconds, microseconds or nanoseconds respectively.
1112
1130
1113
-
The parser will raise one of ``ValueError/TypeError/AssertionError`` if the JSON is
1114
-
not parsable.
1131
+
The parser will raise one of ``ValueError/TypeError/AssertionError`` if the JSON is not parsable.
1115
1132
1116
1133
The default of ``convert_axes=True``, ``dtype=True``, and ``convert_dates=True`` will try to parse the axes, and all of the data
1117
1134
into appropriate types, including dates. If you need to override specific dtypes, pass a dict to ``dtype``. ``convert_axes`` should only
1118
1135
be set to ``False`` if you need to preserve string-like numbers (e.g. '1', '2') in an axes.
1119
1136
1137
+
.. note::
1138
+
1139
+
Large integer values may be converted to dates if ``convert_dates=True`` and the data and / or column labels appear 'date-like'. The exact threshold depends on the ``date_unit`` specified.
1140
+
1120
1141
.. warning::
1121
1142
1122
1143
When reading JSON data, automatic coercing into dtypes has some quirks:
@@ -1143,13 +1164,13 @@ Don't convert any data (but still convert axes and dates)
0 commit comments