@@ -337,7 +337,7 @@ def _convert_listlike_datetimes(
337337 unit : str
338338 None or string of the frequency of the passed data
339339 errors : str
340- error handing behaviors from to_datetime, 'raise', 'coerce', 'ignore'
340+ error handing behaviors from to_datetime, 'raise', 'coerce'
341341 dayfirst : bool
342342 dayfirst parsing behavior from to_datetime
343343 yearfirst : bool
@@ -387,7 +387,6 @@ def _convert_listlike_datetimes(
387387 if not is_supported_dtype (arg_dtype ):
388388 # We go to closest supported reso, i.e. "s"
389389 arg = astype_overflowsafe (
390- # TODO: looks like we incorrectly raise with errors=="ignore"
391390 np .asarray (arg ),
392391 np .dtype ("M8[s]" ),
393392 is_coerce = errors == "coerce" ,
@@ -418,9 +417,6 @@ def _convert_listlike_datetimes(
418417 if errors == "coerce" :
419418 npvalues = np .array (["NaT" ], dtype = "datetime64[ns]" ).repeat (len (arg ))
420419 return DatetimeIndex (npvalues , name = name )
421- elif errors == "ignore" :
422- idx = Index (arg , name = name )
423- return idx
424420 raise
425421
426422 arg = ensure_object (arg )
@@ -525,12 +521,7 @@ def _to_datetime_with_unit(arg, unit, name, utc: bool, errors: str) -> Index:
525521 arg = arg .astype (object , copy = False )
526522 arr , tz_parsed = tslib .array_with_unit_to_datetime (arg , unit , errors = errors )
527523
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 )
534525 if not isinstance (result , DatetimeIndex ):
535526 return result
536527
@@ -629,7 +620,6 @@ def to_datetime(
629620 format : str | None = ...,
630621 exact : bool = ...,
631622 unit : str | None = ...,
632- infer_datetime_format : bool = ...,
633623 origin = ...,
634624 cache : bool = ...,
635625) -> Timestamp :
@@ -646,7 +636,6 @@ def to_datetime(
646636 format : str | None = ...,
647637 exact : bool = ...,
648638 unit : str | None = ...,
649- infer_datetime_format : bool = ...,
650639 origin = ...,
651640 cache : bool = ...,
652641) -> Series :
@@ -663,7 +652,6 @@ def to_datetime(
663652 format : str | None = ...,
664653 exact : bool = ...,
665654 unit : str | None = ...,
666- infer_datetime_format : bool = ...,
667655 origin = ...,
668656 cache : bool = ...,
669657) -> DatetimeIndex :
@@ -679,7 +667,6 @@ def to_datetime(
679667 format : str | None = None ,
680668 exact : bool | lib .NoDefault = lib .no_default ,
681669 unit : str | None = None ,
682- infer_datetime_format : lib .NoDefault | bool = lib .no_default ,
683670 origin : str = "unix" ,
684671 cache : bool = True ,
685672) -> DatetimeIndex | Series | DatetimeScalar | NaTType | None :
@@ -696,10 +683,9 @@ def to_datetime(
696683 method expects minimally the following columns: :const:`"year"`,
697684 :const:`"month"`, :const:`"day"`. The column "year"
698685 must be specified in 4-digit format.
699- errors : {'ignore', ' raise', 'coerce'}, default 'raise'
686+ errors : {'raise', 'coerce'}, default 'raise'
700687 - If :const:`'raise'`, then invalid parsing will raise an exception.
701688 - If :const:`'coerce'`, then invalid parsing will be set as :const:`NaT`.
702- - If :const:`'ignore'`, then invalid parsing will return the input.
703689 dayfirst : bool, default False
704690 Specify a date parse order if `arg` is str or is list-like.
705691 If :const:`True`, parses dates with the day first, e.g. :const:`"10/11/12"`
@@ -780,16 +766,6 @@ def to_datetime(
780766 integer or float number. This will be based off the origin.
781767 Example, with ``unit='ms'`` and ``origin='unix'``, this would calculate
782768 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-
793769 origin : scalar, default 'unix'
794770 Define the reference date. The numeric values would be parsed as number
795771 of units (defined by `unit`) since this reference date.
@@ -1012,25 +988,6 @@ def to_datetime(
1012988 """
1013989 if exact is not lib .no_default and format in {"mixed" , "ISO8601" }:
1014990 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-
1034991 if arg is None :
1035992 return None
1036993
@@ -1141,11 +1098,10 @@ def _assemble_from_unit_mappings(
11411098 Parameters
11421099 ----------
11431100 arg : DataFrame
1144- errors : {'ignore', ' raise', 'coerce'}, default 'raise'
1101+ errors : {'raise', 'coerce'}, default 'raise'
11451102
11461103 - If :const:`'raise'`, then invalid parsing will raise an exception
11471104 - If :const:`'coerce'`, then invalid parsing will be set as :const:`NaT`
1148- - If :const:`'ignore'`, then invalid parsing will return the input
11491105 utc : bool
11501106 Whether to convert/localize timestamps to UTC.
11511107
0 commit comments