@@ -406,8 +406,6 @@ def read_json(
406
406
typ : Literal ["frame" ] = ...,
407
407
dtype : DtypeArg | None = ...,
408
408
convert_axes : bool | None = ...,
409
- convert_dates : bool | list [str ] = ...,
410
- keep_default_dates : bool = ...,
411
409
precise_float : bool = ...,
412
410
date_unit : str | None = ...,
413
411
encoding : str | None = ...,
@@ -430,8 +428,6 @@ def read_json(
430
428
typ : Literal ["series" ],
431
429
dtype : DtypeArg | None = ...,
432
430
convert_axes : bool | None = ...,
433
- convert_dates : bool | list [str ] = ...,
434
- keep_default_dates : bool = ...,
435
431
precise_float : bool = ...,
436
432
date_unit : str | None = ...,
437
433
encoding : str | None = ...,
@@ -454,8 +450,6 @@ def read_json(
454
450
typ : Literal ["series" ],
455
451
dtype : DtypeArg | None = ...,
456
452
convert_axes : bool | None = ...,
457
- convert_dates : bool | list [str ] = ...,
458
- keep_default_dates : bool = ...,
459
453
precise_float : bool = ...,
460
454
date_unit : str | None = ...,
461
455
encoding : str | None = ...,
@@ -478,8 +472,6 @@ def read_json(
478
472
typ : Literal ["frame" ] = ...,
479
473
dtype : DtypeArg | None = ...,
480
474
convert_axes : bool | None = ...,
481
- convert_dates : bool | list [str ] = ...,
482
- keep_default_dates : bool = ...,
483
475
precise_float : bool = ...,
484
476
date_unit : str | None = ...,
485
477
encoding : str | None = ...,
@@ -505,8 +497,6 @@ def read_json(
505
497
typ : Literal ["frame" , "series" ] = "frame" ,
506
498
dtype : DtypeArg | None = None ,
507
499
convert_axes : bool | None = None ,
508
- convert_dates : bool | list [str ] = True ,
509
- keep_default_dates : bool = True ,
510
500
precise_float : bool = False ,
511
501
date_unit : str | None = None ,
512
502
encoding : str | None = None ,
@@ -588,29 +578,6 @@ def read_json(
588
578
589
579
For all ``orient`` values except ``'table'``, default is True.
590
580
591
- convert_dates : bool or list of str, default True
592
- If True then default datelike columns may be converted (depending on
593
- keep_default_dates).
594
- If False, no dates will be converted.
595
- If a list of column names, then those columns will be converted and
596
- default datelike columns may also be converted (depending on
597
- keep_default_dates).
598
-
599
- keep_default_dates : bool, default True
600
- If parsing dates (convert_dates is not False), then try to parse the
601
- default datelike columns.
602
- A column label is datelike if
603
-
604
- * it ends with ``'_at'``,
605
-
606
- * it ends with ``'_time'``,
607
-
608
- * it begins with ``'timestamp'``,
609
-
610
- * it is ``'modified'``, or
611
-
612
- * it is ``'date'``.
613
-
614
581
precise_float : bool, default False
615
582
Set to enable usage of higher precision (strtod) function when
616
583
decoding string to double values. Default (False) is to use fast but
@@ -786,8 +753,6 @@ def read_json(
786
753
typ = typ ,
787
754
dtype = dtype ,
788
755
convert_axes = convert_axes ,
789
- convert_dates = convert_dates ,
790
- keep_default_dates = keep_default_dates ,
791
756
precise_float = precise_float ,
792
757
date_unit = date_unit ,
793
758
encoding = encoding ,
@@ -823,8 +788,6 @@ def __init__(
823
788
typ : FrameSeriesStrT ,
824
789
dtype ,
825
790
convert_axes : bool | None ,
826
- convert_dates ,
827
- keep_default_dates : bool ,
828
791
precise_float : bool ,
829
792
date_unit ,
830
793
encoding ,
@@ -841,8 +804,6 @@ def __init__(
841
804
self .typ = typ
842
805
self .dtype = dtype
843
806
self .convert_axes = convert_axes
844
- self .convert_dates = convert_dates
845
- self .keep_default_dates = keep_default_dates
846
807
self .precise_float = precise_float
847
808
self .date_unit = date_unit
848
809
self .encoding = encoding
@@ -982,8 +943,6 @@ def _get_object_parser(self, json: str) -> DataFrame | Series:
982
943
"orient" : self .orient ,
983
944
"dtype" : self .dtype ,
984
945
"convert_axes" : self .convert_axes ,
985
- "convert_dates" : self .convert_dates ,
986
- "keep_default_dates" : self .keep_default_dates ,
987
946
"precise_float" : self .precise_float ,
988
947
"date_unit" : self .date_unit ,
989
948
"dtype_backend" : self .dtype_backend ,
@@ -1080,8 +1039,6 @@ def __init__(
1080
1039
orient ,
1081
1040
dtype : DtypeArg | None = None ,
1082
1041
convert_axes : bool = True ,
1083
- convert_dates : bool | list [str ] = True ,
1084
- keep_default_dates : bool = False ,
1085
1042
precise_float : bool = False ,
1086
1043
date_unit = None ,
1087
1044
dtype_backend : DtypeBackend | lib .NoDefault = lib .no_default ,
@@ -1105,9 +1062,7 @@ def __init__(
1105
1062
1106
1063
self .precise_float = precise_float
1107
1064
self .convert_axes = convert_axes
1108
- self .convert_dates = convert_dates
1109
1065
self .date_unit = date_unit
1110
- self .keep_default_dates = keep_default_dates
1111
1066
self .dtype_backend = dtype_backend
1112
1067
1113
1068
@final
@@ -1144,7 +1099,6 @@ def _convert_axes(self, obj: DataFrame | Series) -> DataFrame | Series:
1144
1099
name = axis_name ,
1145
1100
data = ser ,
1146
1101
use_dtypes = False ,
1147
- convert_dates = True ,
1148
1102
is_axis = True ,
1149
1103
)
1150
1104
if result :
@@ -1161,7 +1115,6 @@ def _try_convert_data(
1161
1115
name : Hashable ,
1162
1116
data : Series ,
1163
1117
use_dtypes : bool = True ,
1164
- convert_dates : bool | list [str ] = True ,
1165
1118
is_axis : bool = False ,
1166
1119
) -> tuple [Series , bool ]:
1167
1120
"""
@@ -1179,10 +1132,7 @@ def _try_convert_data(
1179
1132
1180
1133
elif self .dtype is True :
1181
1134
pass
1182
- elif not _should_convert_dates (
1183
- convert_dates , self .keep_default_dates , name
1184
- ):
1185
- # convert_dates takes precedence over columns listed in dtypes
1135
+ else :
1186
1136
dtype = (
1187
1137
self .dtype .get (name ) if isinstance (self .dtype , dict ) else self .dtype
1188
1138
)
@@ -1192,11 +1142,6 @@ def _try_convert_data(
1192
1142
except (TypeError , ValueError ):
1193
1143
return data , False
1194
1144
1195
- if convert_dates :
1196
- new_data = self ._try_convert_to_date (data )
1197
- if new_data is not data :
1198
- return new_data , True
1199
-
1200
1145
converted = False
1201
1146
if self .dtype_backend is not lib .no_default and not is_axis :
1202
1147
# Fall through for conversion later on
@@ -1302,7 +1247,7 @@ def _parse(self) -> Series:
1302
1247
return Series (data )
1303
1248
1304
1249
def _try_convert_types (self , obj : Series ) -> Series :
1305
- obj , _ = self ._try_convert_data ("data" , obj , convert_dates = self . convert_dates )
1250
+ obj , _ = self ._try_convert_data ("data" , obj )
1306
1251
return obj
1307
1252
1308
1253
@@ -1349,40 +1294,8 @@ def _try_convert_types(self, obj: DataFrame) -> DataFrame:
1349
1294
result , _ = self ._try_convert_data (
1350
1295
col_label ,
1351
1296
series ,
1352
- convert_dates = _should_convert_dates (
1353
- self .convert_dates ,
1354
- keep_default_dates = self .keep_default_dates ,
1355
- col = col_label ,
1356
- ),
1357
1297
)
1358
1298
arrays .append (result .array )
1359
1299
return DataFrame ._from_arrays (
1360
1300
arrays , obj .columns , obj .index , verify_integrity = False
1361
1301
)
1362
-
1363
-
1364
- def _should_convert_dates (
1365
- convert_dates : bool | list [str ],
1366
- keep_default_dates : bool ,
1367
- col : Hashable ,
1368
- ) -> bool :
1369
- """
1370
- Return bool whether a DataFrame column should be cast to datetime.
1371
- """
1372
- if convert_dates is False :
1373
- # convert_dates=True means follow keep_default_dates
1374
- return False
1375
- elif not isinstance (convert_dates , bool ) and col in set (convert_dates ):
1376
- return True
1377
- elif not keep_default_dates :
1378
- return False
1379
- elif not isinstance (col , str ):
1380
- return False
1381
- col_lower = col .lower ()
1382
- if (
1383
- col_lower .endswith (("_at" , "_time" ))
1384
- or col_lower in {"modified" , "date" , "datetime" }
1385
- or col_lower .startswith ("timestamp" )
1386
- ):
1387
- return True
1388
- return False
0 commit comments