Skip to content

Commit e6edc47

Browse files
authored
CLN: Remove deprecated read_csv(infer_datetime_format=) (pandas-dev#58620)
1 parent 3e65640 commit e6edc47

File tree

4 files changed

+1
-60
lines changed

4 files changed

+1
-60
lines changed

doc/source/user_guide/io.rst

-7
Original file line numberDiff line numberDiff line change
@@ -276,12 +276,6 @@ parse_dates : boolean or list of ints or names or list of lists or dict, default
276276

277277
.. note::
278278
A fast-path exists for iso8601-formatted dates.
279-
infer_datetime_format : boolean, default ``False``
280-
If ``True`` and parse_dates is enabled for a column, attempt to infer the
281-
datetime format to speed up the processing.
282-
283-
.. deprecated:: 2.0.0
284-
A strict version of this argument is now the default, passing it has no effect.
285279
keep_date_col : boolean, default ``False``
286280
If ``True`` and parse_dates specifies combining multiple columns then keep the
287281
original columns.
@@ -1639,7 +1633,6 @@ Options that are unsupported by the pyarrow engine which are not covered by the
16391633
* ``decimal``
16401634
* ``iterator``
16411635
* ``dayfirst``
1642-
* ``infer_datetime_format``
16431636
* ``verbose``
16441637
* ``skipinitialspace``
16451638
* ``low_memory``

doc/source/whatsnew/v3.0.0.rst

+1
Original file line numberDiff line numberDiff line change
@@ -255,6 +255,7 @@ Removal of prior version deprecations/changes
255255
- Enforced deprecation of ``axis=None`` acting the same as ``axis=0`` in the DataFrame reductions ``sum``, ``prod``, ``std``, ``var``, and ``sem``, passing ``axis=None`` will now reduce over both axes; this is particularly the case when doing e.g. ``numpy.sum(df)`` (:issue:`21597`)
256256
- Enforced deprecation of ``core.internals`` members ``Block``, ``ExtensionBlock``, and ``DatetimeTZBlock`` (:issue:`58467`)
257257
- Enforced deprecation of ``quantile`` keyword in :meth:`.Rolling.quantile` and :meth:`.Expanding.quantile`, renamed to ``q`` instead. (:issue:`52550`)
258+
- Enforced deprecation of argument ``infer_datetime_format`` in :func:`read_csv`, as a strict version of it is now the default (:issue:`48621`)
258259
- Enforced deprecation of non-standard (``np.ndarray``, :class:`ExtensionArray`, :class:`Index`, or :class:`Series`) argument to :func:`api.extensions.take` (:issue:`52981`)
259260
- Enforced deprecation of parsing system timezone strings to ``tzlocal``, which depended on system timezone, pass the 'tz' keyword instead (:issue:`50791`)
260261
- Enforced deprecation of passing a dictionary to :meth:`SeriesGroupBy.agg` (:issue:`52268`)

pandas/io/parsers/readers.py

-34
Original file line numberDiff line numberDiff line change
@@ -118,7 +118,6 @@ class _read_shared(TypedDict, Generic[HashableT], total=False):
118118
na_filter: bool
119119
skip_blank_lines: bool
120120
parse_dates: bool | Sequence[Hashable] | None
121-
infer_datetime_format: bool | lib.NoDefault
122121
keep_date_col: bool | lib.NoDefault
123122
date_parser: Callable | lib.NoDefault
124123
date_format: str | dict[Hashable, str] | None
@@ -323,15 +322,6 @@ class _read_shared(TypedDict, Generic[HashableT], total=False):
323322
:func:`~pandas.read_csv`.
324323
325324
Note: A fast-path exists for iso8601-formatted dates.
326-
infer_datetime_format : bool, default False
327-
If ``True`` and ``parse_dates`` is enabled, pandas will attempt to infer the
328-
format of the ``datetime`` strings in the columns, and if it can be inferred,
329-
switch to a faster method of parsing them. In some cases this can increase
330-
the parsing speed by 5-10x.
331-
332-
.. deprecated:: 2.0.0
333-
A strict version of this argument is now the default, passing it has no effect.
334-
335325
keep_date_col : bool, default False
336326
If ``True`` and ``parse_dates`` specifies combining multiple columns then
337327
keep the original columns.
@@ -758,7 +748,6 @@ def read_csv(
758748
skip_blank_lines: bool = True,
759749
# Datetime Handling
760750
parse_dates: bool | Sequence[Hashable] | None = None,
761-
infer_datetime_format: bool | lib.NoDefault = lib.no_default,
762751
keep_date_col: bool | lib.NoDefault = lib.no_default,
763752
date_parser: Callable | lib.NoDefault = lib.no_default,
764753
date_format: str | dict[Hashable, str] | None = None,
@@ -822,17 +811,6 @@ def read_csv(
822811
stacklevel=find_stack_level(),
823812
)
824813

825-
if infer_datetime_format is not lib.no_default:
826-
warnings.warn(
827-
"The argument 'infer_datetime_format' is deprecated and will "
828-
"be removed in a future version. "
829-
"A strict version of it is now the default, see "
830-
"https://pandas.pydata.org/pdeps/0004-consistent-to-datetime-parsing.html. "
831-
"You can safely remove this argument.",
832-
FutureWarning,
833-
stacklevel=find_stack_level(),
834-
)
835-
836814
if delim_whitespace is not lib.no_default:
837815
# GH#55569
838816
warnings.warn(
@@ -949,7 +927,6 @@ def read_table(
949927
skip_blank_lines: bool = True,
950928
# Datetime Handling
951929
parse_dates: bool | Sequence[Hashable] | None = None,
952-
infer_datetime_format: bool | lib.NoDefault = lib.no_default,
953930
keep_date_col: bool | lib.NoDefault = lib.no_default,
954931
date_parser: Callable | lib.NoDefault = lib.no_default,
955932
date_format: str | dict[Hashable, str] | None = None,
@@ -1004,17 +981,6 @@ def read_table(
1004981
stacklevel=find_stack_level(),
1005982
)
1006983

1007-
if infer_datetime_format is not lib.no_default:
1008-
warnings.warn(
1009-
"The argument 'infer_datetime_format' is deprecated and will "
1010-
"be removed in a future version. "
1011-
"A strict version of it is now the default, see "
1012-
"https://pandas.pydata.org/pdeps/0004-consistent-to-datetime-parsing.html. "
1013-
"You can safely remove this argument.",
1014-
FutureWarning,
1015-
stacklevel=find_stack_level(),
1016-
)
1017-
1018984
if delim_whitespace is not lib.no_default:
1019985
# GH#55569
1020986
warnings.warn(

pandas/tests/io/parser/test_parse_dates.py

-19
Original file line numberDiff line numberDiff line change
@@ -1383,25 +1383,6 @@ def test_parse_dates_empty_string(all_parsers):
13831383
tm.assert_frame_equal(result, expected)
13841384

13851385

1386-
@pytest.mark.parametrize(
1387-
"reader", ["read_csv_check_warnings", "read_table_check_warnings"]
1388-
)
1389-
def test_parse_dates_infer_datetime_format_warning(all_parsers, reader):
1390-
# GH 49024, 51017
1391-
parser = all_parsers
1392-
data = "Date,test\n2012-01-01,1\n,2"
1393-
1394-
getattr(parser, reader)(
1395-
FutureWarning,
1396-
"The argument 'infer_datetime_format' is deprecated",
1397-
StringIO(data),
1398-
parse_dates=["Date"],
1399-
infer_datetime_format=True,
1400-
sep=",",
1401-
raise_on_extra_warnings=False,
1402-
)
1403-
1404-
14051386
@pytest.mark.parametrize(
14061387
"reader", ["read_csv_check_warnings", "read_table_check_warnings"]
14071388
)

0 commit comments

Comments
 (0)