Skip to content

Commit 0d43f68

Browse files
authored
ENH, TST: Add FutureWarning to read_table (#51048)
* Add FutureWarning to read_table * Update test function * Add warning type * Update read_csv() with FutureWarning * Resolving pre-commit-hook changes * Revert pre-commit-config.yaml
1 parent ae1d9c9 commit 0d43f68

File tree

3 files changed

+22
-5
lines changed

3 files changed

+22
-5
lines changed

.pre-commit-config.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,7 @@ repos:
9292
args: [--disable=all, --enable=redefined-outer-name]
9393
stages: [manual]
9494
- repo: https://github.com/PyCQA/isort
95-
rev: 5.11.4
95+
rev: 5.12.0
9696
hooks:
9797
- id: isort
9898
- repo: https://github.com/asottile/pyupgrade

pandas/io/parsers/readers.py

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -891,6 +891,7 @@ def read_csv(
891891
"A strict version of it is now the default, see "
892892
"https://pandas.pydata.org/pdeps/0004-consistent-to-datetime-parsing.html. "
893893
"You can safely remove this argument.",
894+
FutureWarning,
894895
stacklevel=find_stack_level(),
895896
)
896897
# locals() should never be modified
@@ -1207,6 +1208,17 @@ def read_table(
12071208
storage_options: StorageOptions = None,
12081209
use_nullable_dtypes: bool | lib.NoDefault = lib.no_default,
12091210
) -> DataFrame | TextFileReader:
1211+
if infer_datetime_format is not lib.no_default:
1212+
warnings.warn(
1213+
"The argument 'infer_datetime_format' is deprecated and will "
1214+
"be removed in a future version. "
1215+
"A strict version of it is now the default, see "
1216+
"https://pandas.pydata.org/pdeps/0004-consistent-to-datetime-parsing.html. "
1217+
"You can safely remove this argument.",
1218+
FutureWarning,
1219+
stacklevel=find_stack_level(),
1220+
)
1221+
12101222
# locals() should never be modified
12111223
kwds = locals().copy()
12121224
del kwds["filepath_or_buffer"]

pandas/tests/io/parser/test_parse_dates.py

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1290,16 +1290,21 @@ def test_parse_dates_empty_string(all_parsers):
12901290
tm.assert_frame_equal(result, expected)
12911291

12921292

1293-
def test_parse_dates_infer_datetime_format_warning(all_parsers):
1294-
# GH 49024
1293+
@pytest.mark.parametrize(
1294+
"reader", ["read_csv_check_warnings", "read_table_check_warnings"]
1295+
)
1296+
def test_parse_dates_infer_datetime_format_warning(all_parsers, reader):
1297+
# GH 49024, 51017
12951298
parser = all_parsers
12961299
data = "Date,test\n2012-01-01,1\n,2"
1297-
parser.read_csv_check_warnings(
1298-
UserWarning,
1300+
1301+
getattr(parser, reader)(
1302+
FutureWarning,
12991303
"The argument 'infer_datetime_format' is deprecated",
13001304
StringIO(data),
13011305
parse_dates=["Date"],
13021306
infer_datetime_format=True,
1307+
sep=",",
13031308
)
13041309

13051310

0 commit comments

Comments
 (0)