Skip to content

CLN: Remove deprecated read_csv(infer_datetime_format=) #58620

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
May 7, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 0 additions & 7 deletions doc/source/user_guide/io.rst
Original file line number Diff line number Diff line change
Expand Up @@ -276,12 +276,6 @@ parse_dates : boolean or list of ints or names or list of lists or dict, default

.. note::
A fast-path exists for iso8601-formatted dates.
infer_datetime_format : boolean, default ``False``
If ``True`` and parse_dates is enabled for a column, attempt to infer the
datetime format to speed up the processing.

.. deprecated:: 2.0.0
A strict version of this argument is now the default, passing it has no effect.
keep_date_col : boolean, default ``False``
If ``True`` and parse_dates specifies combining multiple columns then keep the
original columns.
Expand Down Expand Up @@ -1639,7 +1633,6 @@ Options that are unsupported by the pyarrow engine which are not covered by the
* ``decimal``
* ``iterator``
* ``dayfirst``
* ``infer_datetime_format``
* ``verbose``
* ``skipinitialspace``
* ``low_memory``
Expand Down
1 change: 1 addition & 0 deletions doc/source/whatsnew/v3.0.0.rst
Original file line number Diff line number Diff line change
Expand Up @@ -254,6 +254,7 @@ Removal of prior version deprecations/changes
- Enforced deprecation of :meth:`offsets.Tick.delta`, use ``pd.Timedelta(obj)`` instead (:issue:`55498`)
- 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`)
- Enforced deprecation of ``core.internals`` members ``Block``, ``ExtensionBlock``, and ``DatetimeTZBlock`` (:issue:`58467`)
- Enforced deprecation of argument ``infer_datetime_format`` in :func:`read_csv`, as a strict version of it is now the default (:issue:`48621`)
- Enforced deprecation of non-standard (``np.ndarray``, :class:`ExtensionArray`, :class:`Index`, or :class:`Series`) argument to :func:`api.extensions.take` (:issue:`52981`)
- Enforced deprecation of parsing system timezone strings to ``tzlocal``, which depended on system timezone, pass the 'tz' keyword instead (:issue:`50791`)
- Enforced deprecation of passing a dictionary to :meth:`SeriesGroupBy.agg` (:issue:`52268`)
Expand Down
34 changes: 0 additions & 34 deletions pandas/io/parsers/readers.py
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,6 @@ class _read_shared(TypedDict, Generic[HashableT], total=False):
na_filter: bool
skip_blank_lines: bool
parse_dates: bool | Sequence[Hashable] | None
infer_datetime_format: bool | lib.NoDefault
keep_date_col: bool | lib.NoDefault
date_parser: Callable | lib.NoDefault
date_format: str | dict[Hashable, str] | None
Expand Down Expand Up @@ -323,15 +322,6 @@ class _read_shared(TypedDict, Generic[HashableT], total=False):
:func:`~pandas.read_csv`.

Note: A fast-path exists for iso8601-formatted dates.
infer_datetime_format : bool, default False
If ``True`` and ``parse_dates`` is enabled, pandas will attempt to infer the
format of the ``datetime`` strings in the columns, and if it can be inferred,
switch to a faster method of parsing them. In some cases this can increase
the parsing speed by 5-10x.

.. deprecated:: 2.0.0
A strict version of this argument is now the default, passing it has no effect.

keep_date_col : bool, default False
If ``True`` and ``parse_dates`` specifies combining multiple columns then
keep the original columns.
Expand Down Expand Up @@ -758,7 +748,6 @@ def read_csv(
skip_blank_lines: bool = True,
# Datetime Handling
parse_dates: bool | Sequence[Hashable] | None = None,
infer_datetime_format: bool | lib.NoDefault = lib.no_default,
keep_date_col: bool | lib.NoDefault = lib.no_default,
date_parser: Callable | lib.NoDefault = lib.no_default,
date_format: str | dict[Hashable, str] | None = None,
Expand Down Expand Up @@ -822,17 +811,6 @@ def read_csv(
stacklevel=find_stack_level(),
)

if infer_datetime_format is not lib.no_default:
warnings.warn(
"The argument 'infer_datetime_format' is deprecated and will "
"be removed in a future version. "
"A strict version of it is now the default, see "
"https://pandas.pydata.org/pdeps/0004-consistent-to-datetime-parsing.html. "
"You can safely remove this argument.",
FutureWarning,
stacklevel=find_stack_level(),
)

if delim_whitespace is not lib.no_default:
# GH#55569
warnings.warn(
Expand Down Expand Up @@ -949,7 +927,6 @@ def read_table(
skip_blank_lines: bool = True,
# Datetime Handling
parse_dates: bool | Sequence[Hashable] | None = None,
infer_datetime_format: bool | lib.NoDefault = lib.no_default,
keep_date_col: bool | lib.NoDefault = lib.no_default,
date_parser: Callable | lib.NoDefault = lib.no_default,
date_format: str | dict[Hashable, str] | None = None,
Expand Down Expand Up @@ -1004,17 +981,6 @@ def read_table(
stacklevel=find_stack_level(),
)

if infer_datetime_format is not lib.no_default:
warnings.warn(
"The argument 'infer_datetime_format' is deprecated and will "
"be removed in a future version. "
"A strict version of it is now the default, see "
"https://pandas.pydata.org/pdeps/0004-consistent-to-datetime-parsing.html. "
"You can safely remove this argument.",
FutureWarning,
stacklevel=find_stack_level(),
)

if delim_whitespace is not lib.no_default:
# GH#55569
warnings.warn(
Expand Down
19 changes: 0 additions & 19 deletions pandas/tests/io/parser/test_parse_dates.py
Original file line number Diff line number Diff line change
Expand Up @@ -1383,25 +1383,6 @@ def test_parse_dates_empty_string(all_parsers):
tm.assert_frame_equal(result, expected)


@pytest.mark.parametrize(
"reader", ["read_csv_check_warnings", "read_table_check_warnings"]
)
def test_parse_dates_infer_datetime_format_warning(all_parsers, reader):
# GH 49024, 51017
parser = all_parsers
data = "Date,test\n2012-01-01,1\n,2"

getattr(parser, reader)(
FutureWarning,
"The argument 'infer_datetime_format' is deprecated",
StringIO(data),
parse_dates=["Date"],
infer_datetime_format=True,
sep=",",
raise_on_extra_warnings=False,
)


@pytest.mark.parametrize(
"reader", ["read_csv_check_warnings", "read_table_check_warnings"]
)
Expand Down