Skip to content

ENH, TST: Add FutureWarning to read_table #51048

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 6 commits into from
Jan 30, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
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
2 changes: 1 addition & 1 deletion .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ repos:
args: [--disable=all, --enable=redefined-outer-name]
stages: [manual]
- repo: https://github.com/PyCQA/isort
rev: 5.11.4
rev: 5.12.0
hooks:
- id: isort
- repo: https://github.com/asottile/pyupgrade
Expand Down
12 changes: 12 additions & 0 deletions pandas/io/parsers/readers.py
Original file line number Diff line number Diff line change
Expand Up @@ -891,6 +891,7 @@ def read_csv(
"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(),
)
# locals() should never be modified
Expand Down Expand Up @@ -1207,6 +1208,17 @@ def read_table(
storage_options: StorageOptions = None,
use_nullable_dtypes: bool | lib.NoDefault = lib.no_default,
) -> DataFrame | TextFileReader:
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(),
)

# locals() should never be modified
kwds = locals().copy()
del kwds["filepath_or_buffer"]
Expand Down
13 changes: 9 additions & 4 deletions pandas/tests/io/parser/test_parse_dates.py
Original file line number Diff line number Diff line change
Expand Up @@ -1290,16 +1290,21 @@ def test_parse_dates_empty_string(all_parsers):
tm.assert_frame_equal(result, expected)


def test_parse_dates_infer_datetime_format_warning(all_parsers):
# GH 49024
@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"
parser.read_csv_check_warnings(
UserWarning,

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


Expand Down