@@ -337,7 +337,7 @@ def _convert_listlike_datetimes(
337
337
unit : str
338
338
None or string of the frequency of the passed data
339
339
errors : str
340
- error handing behaviors from to_datetime, 'raise', 'coerce', 'ignore'
340
+ error handing behaviors from to_datetime, 'raise', 'coerce'
341
341
dayfirst : bool
342
342
dayfirst parsing behavior from to_datetime
343
343
yearfirst : bool
@@ -387,7 +387,6 @@ def _convert_listlike_datetimes(
387
387
if not is_supported_dtype (arg_dtype ):
388
388
# We go to closest supported reso, i.e. "s"
389
389
arg = astype_overflowsafe (
390
- # TODO: looks like we incorrectly raise with errors=="ignore"
391
390
np .asarray (arg ),
392
391
np .dtype ("M8[s]" ),
393
392
is_coerce = errors == "coerce" ,
@@ -418,9 +417,6 @@ def _convert_listlike_datetimes(
418
417
if errors == "coerce" :
419
418
npvalues = np .array (["NaT" ], dtype = "datetime64[ns]" ).repeat (len (arg ))
420
419
return DatetimeIndex (npvalues , name = name )
421
- elif errors == "ignore" :
422
- idx = Index (arg , name = name )
423
- return idx
424
420
raise
425
421
426
422
arg = ensure_object (arg )
@@ -525,12 +521,7 @@ def _to_datetime_with_unit(arg, unit, name, utc: bool, errors: str) -> Index:
525
521
arg = arg .astype (object , copy = False )
526
522
arr , tz_parsed = tslib .array_with_unit_to_datetime (arg , unit , errors = errors )
527
523
528
- if errors == "ignore" :
529
- # Index constructor _may_ infer to DatetimeIndex
530
- result = Index ._with_infer (arr , name = name )
531
- else :
532
- result = DatetimeIndex (arr , name = name )
533
-
524
+ result = DatetimeIndex (arr , name = name )
534
525
if not isinstance (result , DatetimeIndex ):
535
526
return result
536
527
@@ -629,7 +620,6 @@ def to_datetime(
629
620
format : str | None = ...,
630
621
exact : bool = ...,
631
622
unit : str | None = ...,
632
- infer_datetime_format : bool = ...,
633
623
origin = ...,
634
624
cache : bool = ...,
635
625
) -> Timestamp :
@@ -646,7 +636,6 @@ def to_datetime(
646
636
format : str | None = ...,
647
637
exact : bool = ...,
648
638
unit : str | None = ...,
649
- infer_datetime_format : bool = ...,
650
639
origin = ...,
651
640
cache : bool = ...,
652
641
) -> Series :
@@ -663,7 +652,6 @@ def to_datetime(
663
652
format : str | None = ...,
664
653
exact : bool = ...,
665
654
unit : str | None = ...,
666
- infer_datetime_format : bool = ...,
667
655
origin = ...,
668
656
cache : bool = ...,
669
657
) -> DatetimeIndex :
@@ -679,7 +667,6 @@ def to_datetime(
679
667
format : str | None = None ,
680
668
exact : bool | lib .NoDefault = lib .no_default ,
681
669
unit : str | None = None ,
682
- infer_datetime_format : lib .NoDefault | bool = lib .no_default ,
683
670
origin : str = "unix" ,
684
671
cache : bool = True ,
685
672
) -> DatetimeIndex | Series | DatetimeScalar | NaTType | None :
@@ -696,10 +683,9 @@ def to_datetime(
696
683
method expects minimally the following columns: :const:`"year"`,
697
684
:const:`"month"`, :const:`"day"`. The column "year"
698
685
must be specified in 4-digit format.
699
- errors : {'ignore', ' raise', 'coerce'}, default 'raise'
686
+ errors : {'raise', 'coerce'}, default 'raise'
700
687
- If :const:`'raise'`, then invalid parsing will raise an exception.
701
688
- If :const:`'coerce'`, then invalid parsing will be set as :const:`NaT`.
702
- - If :const:`'ignore'`, then invalid parsing will return the input.
703
689
dayfirst : bool, default False
704
690
Specify a date parse order if `arg` is str or is list-like.
705
691
If :const:`True`, parses dates with the day first, e.g. :const:`"10/11/12"`
@@ -780,16 +766,6 @@ def to_datetime(
780
766
integer or float number. This will be based off the origin.
781
767
Example, with ``unit='ms'`` and ``origin='unix'``, this would calculate
782
768
the number of milliseconds to the unix epoch start.
783
- infer_datetime_format : bool, default False
784
- If :const:`True` and no `format` is given, attempt to infer the format
785
- of the datetime strings based on the first non-NaN element,
786
- and if it can be inferred, switch to a faster method of parsing them.
787
- In some cases this can increase the parsing speed by ~5-10x.
788
-
789
- .. deprecated:: 2.0.0
790
- A strict version of this argument is now the default, passing it has
791
- no effect.
792
-
793
769
origin : scalar, default 'unix'
794
770
Define the reference date. The numeric values would be parsed as number
795
771
of units (defined by `unit`) since this reference date.
@@ -1012,25 +988,6 @@ def to_datetime(
1012
988
"""
1013
989
if exact is not lib .no_default and format in {"mixed" , "ISO8601" }:
1014
990
raise ValueError ("Cannot use 'exact' when 'format' is 'mixed' or 'ISO8601'" )
1015
- if infer_datetime_format is not lib .no_default :
1016
- warnings .warn (
1017
- "The argument 'infer_datetime_format' is deprecated and will "
1018
- "be removed in a future version. "
1019
- "A strict version of it is now the default, see "
1020
- "https://pandas.pydata.org/pdeps/0004-consistent-to-datetime-parsing.html. "
1021
- "You can safely remove this argument." ,
1022
- stacklevel = find_stack_level (),
1023
- )
1024
- if errors == "ignore" :
1025
- # GH#54467
1026
- warnings .warn (
1027
- "errors='ignore' is deprecated and will raise in a future version. "
1028
- "Use to_datetime without passing `errors` and catch exceptions "
1029
- "explicitly instead" ,
1030
- FutureWarning ,
1031
- stacklevel = find_stack_level (),
1032
- )
1033
-
1034
991
if arg is None :
1035
992
return None
1036
993
@@ -1141,11 +1098,10 @@ def _assemble_from_unit_mappings(
1141
1098
Parameters
1142
1099
----------
1143
1100
arg : DataFrame
1144
- errors : {'ignore', ' raise', 'coerce'}, default 'raise'
1101
+ errors : {'raise', 'coerce'}, default 'raise'
1145
1102
1146
1103
- If :const:`'raise'`, then invalid parsing will raise an exception
1147
1104
- If :const:`'coerce'`, then invalid parsing will be set as :const:`NaT`
1148
- - If :const:`'ignore'`, then invalid parsing will return the input
1149
1105
utc : bool
1150
1106
Whether to convert/localize timestamps to UTC.
1151
1107
0 commit comments