From fdfc6f4ad63cb2937a073aa152ca0cb25b723ddb Mon Sep 17 00:00:00 2001 From: ramvikrams Date: Wed, 3 May 2023 23:11:46 +0530 Subject: [PATCH 1/9] GH-676 --- pandas-stubs/_typing.pyi | 2 +- tests/test_io.py | 28 ++++++++++++++++++++++++++++ 2 files changed, 29 insertions(+), 1 deletion(-) diff --git a/pandas-stubs/_typing.pyi b/pandas-stubs/_typing.pyi index 6bdb6f91e..74a5a51bd 100644 --- a/pandas-stubs/_typing.pyi +++ b/pandas-stubs/_typing.pyi @@ -76,7 +76,7 @@ class FulldatetimeDict(YearMonthDayDict, total=False): # dtypes NpDtype: TypeAlias = str | np.dtype[np.generic] | type[str | complex | bool | object] Dtype: TypeAlias = ExtensionDtype | NpDtype -DtypeArg: TypeAlias = Dtype | dict[Any, Dtype] +DtypeArg: TypeAlias = Dtype | Mapping[Any, Dtype] DtypeBackend: TypeAlias = Literal["pyarrow", "numpy_nullable"] BooleanDtypeArg: TypeAlias = ( # Builtin bool type and its string alias diff --git a/tests/test_io.py b/tests/test_io.py index 99c069455..41c8c891c 100644 --- a/tests/test_io.py +++ b/tests/test_io.py @@ -1388,3 +1388,31 @@ def test_read_with_lxml_dtype_backend() -> None: check( assert_type(read_xml(path, dtype_backend="pyarrow"), DataFrame), DataFrame ) + + +def test_read_sql_str_dtype() -> None: + with ensure_clean() as path: + con = sqlite3.connect(path) + check(assert_type(DF.to_sql("test", con), Union[int, None]), int) + check( + assert_type( + read_sql_query( + "select * from test", + con=con, + index_col="index", + dtype="int", + ), + DataFrame, + ), + DataFrame, + ) + con.close() + + if TYPE_CHECKING: + # sqlite3 doesn't support read_table, which is required for this function + # Could only run in pytest if SQLAlchemy was installed + with ensure_clean() as path: + co1 = sqlite3.connect(path) + assert_type(DF.to_sql("test", con=co1), Union[int, None]) + assert_type(read_sql_table("test", con=co1, dtype="int"), DataFrame) + co1.close() From 9afff8a87ff74d1b0ef56b676317a13f445d724a Mon Sep 17 00:00:00 2001 From: ramvikrams Date: Wed, 3 May 2023 23:16:21 +0530 Subject: [PATCH 2/9] Update test_io.py --- tests/test_io.py | 9 --------- 1 file changed, 9 deletions(-) diff --git a/tests/test_io.py b/tests/test_io.py index 41c8c891c..e8fcf57fc 100644 --- a/tests/test_io.py +++ b/tests/test_io.py @@ -1407,12 +1407,3 @@ def test_read_sql_str_dtype() -> None: DataFrame, ) con.close() - - if TYPE_CHECKING: - # sqlite3 doesn't support read_table, which is required for this function - # Could only run in pytest if SQLAlchemy was installed - with ensure_clean() as path: - co1 = sqlite3.connect(path) - assert_type(DF.to_sql("test", con=co1), Union[int, None]) - assert_type(read_sql_table("test", con=co1, dtype="int"), DataFrame) - co1.close() From 3f958daba013675f1110637500941e82b46883d6 Mon Sep 17 00:00:00 2001 From: ramvikrams Date: Sat, 6 May 2023 11:22:29 +0530 Subject: [PATCH 3/9] Update tests/test_io.py Co-authored-by: Irv Lustig --- tests/test_io.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/test_io.py b/tests/test_io.py index e8fcf57fc..85d57b218 100644 --- a/tests/test_io.py +++ b/tests/test_io.py @@ -1390,7 +1390,7 @@ def test_read_with_lxml_dtype_backend() -> None: ) -def test_read_sql_str_dtype() -> None: +def test_read_sql_dict_str_value_dtype() -> None: with ensure_clean() as path: con = sqlite3.connect(path) check(assert_type(DF.to_sql("test", con), Union[int, None]), int) From d5719e979d0a1a308daf771d202c07a3e5768e59 Mon Sep 17 00:00:00 2001 From: ramvikrams Date: Sat, 6 May 2023 11:28:34 +0530 Subject: [PATCH 4/9] Update test_io.py --- tests/test_io.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/tests/test_io.py b/tests/test_io.py index 85d57b218..1a5b3c05a 100644 --- a/tests/test_io.py +++ b/tests/test_io.py @@ -1391,6 +1391,7 @@ def test_read_with_lxml_dtype_backend() -> None: def test_read_sql_dict_str_value_dtype() -> None: + # GH 676 with ensure_clean() as path: con = sqlite3.connect(path) check(assert_type(DF.to_sql("test", con), Union[int, None]), int) @@ -1400,7 +1401,7 @@ def test_read_sql_dict_str_value_dtype() -> None: "select * from test", con=con, index_col="index", - dtype="int", + dtype={"a": "int"}, ), DataFrame, ), From c3b50096f1ab5b49ea71a502371814be30778a11 Mon Sep 17 00:00:00 2001 From: ramvikrams Date: Sat, 13 May 2023 10:37:00 +0530 Subject: [PATCH 5/9] added `date_format` to `read_table`,`read_fwf` and `read_excel` --- pandas-stubs/io/excel/_base.pyi | 2 ++ pandas-stubs/io/parsers/readers.pyi | 6 ++++++ tests/test_io.py | 15 +++++++++++++++ 3 files changed, 23 insertions(+) diff --git a/pandas-stubs/io/excel/_base.pyi b/pandas-stubs/io/excel/_base.pyi index 68425625e..5c506dfd4 100644 --- a/pandas-stubs/io/excel/_base.pyi +++ b/pandas-stubs/io/excel/_base.pyi @@ -63,6 +63,7 @@ def read_excel( | Sequence[Sequence[str] | Sequence[int]] | dict[str, Sequence[int] | list[str]] = ..., date_parser: Callable | None = ..., + date_format: dict[Hashable, str] | str | None = ..., thousands: str | None = ..., decimal: str = ..., comment: str | None = ..., @@ -102,6 +103,7 @@ def read_excel( | Sequence[Sequence[str] | Sequence[int]] | dict[str, Sequence[int] | list[str]] = ..., date_parser: Callable | None = ..., + date_format: dict[Hashable, str] | str | None = ..., thousands: str | None = ..., decimal: str = ..., comment: str | None = ..., diff --git a/pandas-stubs/io/parsers/readers.pyi b/pandas-stubs/io/parsers/readers.pyi index 81c20dcc4..d2b23fcfa 100644 --- a/pandas-stubs/io/parsers/readers.pyi +++ b/pandas-stubs/io/parsers/readers.pyi @@ -252,6 +252,7 @@ def read_table( infer_datetime_format: bool = ..., keep_date_col: bool = ..., date_parser: Callable = ..., + date_format: str | None = ..., dayfirst: bool = ..., cache_dates: bool = ..., iterator: Literal[True], @@ -311,6 +312,7 @@ def read_table( infer_datetime_format: bool = ..., keep_date_col: bool = ..., date_parser: Callable = ..., + date_format: str | None = ..., dayfirst: bool = ..., cache_dates: bool = ..., iterator: bool = ..., @@ -370,6 +372,7 @@ def read_table( infer_datetime_format: bool = ..., keep_date_col: bool = ..., date_parser: Callable = ..., + date_format: str | None = ..., dayfirst: bool = ..., cache_dates: bool = ..., iterator: Literal[False] = ..., @@ -402,6 +405,7 @@ def read_fwf( widths: Sequence[int] | None = ..., infer_nrows: int = ..., dtype_backend: DtypeBackend | NoDefault = ..., + date_format: str | None = ..., iterator: Literal[True], chunksize: int | None = ..., **kwds: Any, @@ -414,6 +418,7 @@ def read_fwf( widths: Sequence[int] | None = ..., infer_nrows: int = ..., dtype_backend: DtypeBackend | NoDefault = ..., + date_format: str | None = ..., iterator: bool = ..., chunksize: int, **kwds: Any, @@ -426,6 +431,7 @@ def read_fwf( widths: Sequence[int] | None = ..., infer_nrows: int = ..., dtype_backend: DtypeBackend | NoDefault = ..., + date_format: str | None = ..., iterator: Literal[False] = ..., chunksize: None = ..., **kwds: Any, diff --git a/tests/test_io.py b/tests/test_io.py index ac529eaef..e07cacf5b 100644 --- a/tests/test_io.py +++ b/tests/test_io.py @@ -1405,3 +1405,18 @@ def test_read_sql_dict_str_value_dtype() -> None: DataFrame, ) con.close() + + +def test_added_date_format() -> None: + with ensure_clean() as path: + DF.to_string(path, index=False) + check(assert_type(read_fwf(path, date_format="m"), DataFrame), DataFrame) + check(assert_type(read_table(path, date_format="m"), DataFrame), DataFrame) + with ensure_clean(".xlsx") as path: + check( + assert_type(pd.DataFrame({"A": [1, 2, 3]}).to_excel(path), None), type(None) + ) + check( + assert_type(pd.read_excel(path, date_format={9: "row"}), pd.DataFrame), + pd.DataFrame, + ) From efdb7011900541cfb5bfd65ae64e976230b8ad93 Mon Sep 17 00:00:00 2001 From: ramvikrams Date: Thu, 18 May 2023 12:46:16 +0530 Subject: [PATCH 6/9] req changes --- pandas-stubs/io/excel/_base.pyi | 2 - pandas-stubs/io/parsers/readers.pyi | 17 ++--- tests/test_io.py | 113 ++++++++++++++++++++++++++-- 3 files changed, 114 insertions(+), 18 deletions(-) diff --git a/pandas-stubs/io/excel/_base.pyi b/pandas-stubs/io/excel/_base.pyi index 5c506dfd4..c5638a687 100644 --- a/pandas-stubs/io/excel/_base.pyi +++ b/pandas-stubs/io/excel/_base.pyi @@ -62,7 +62,6 @@ def read_excel( | Sequence[int] | Sequence[Sequence[str] | Sequence[int]] | dict[str, Sequence[int] | list[str]] = ..., - date_parser: Callable | None = ..., date_format: dict[Hashable, str] | str | None = ..., thousands: str | None = ..., decimal: str = ..., @@ -102,7 +101,6 @@ def read_excel( | Sequence[int] | Sequence[Sequence[str] | Sequence[int]] | dict[str, Sequence[int] | list[str]] = ..., - date_parser: Callable | None = ..., date_format: dict[Hashable, str] | str | None = ..., thousands: str | None = ..., decimal: str = ..., diff --git a/pandas-stubs/io/parsers/readers.pyi b/pandas-stubs/io/parsers/readers.pyi index d2b23fcfa..d669f6353 100644 --- a/pandas-stubs/io/parsers/readers.pyi +++ b/pandas-stubs/io/parsers/readers.pyi @@ -4,6 +4,7 @@ from collections import ( ) from collections.abc import ( Callable, + Hashable, Mapping, Sequence, ) @@ -68,7 +69,6 @@ def read_csv( | Mapping[str, Sequence[int | str]] = ..., infer_datetime_format: bool = ..., keep_date_col: bool = ..., - date_parser: Callable = ..., date_format: str | Mapping[int | str, str] | None = ..., dayfirst: bool = ..., cache_dates: bool = ..., @@ -129,7 +129,6 @@ def read_csv( | Mapping[str, Sequence[int | str]] = ..., infer_datetime_format: bool = ..., keep_date_col: bool = ..., - date_parser: Callable = ..., date_format: str | Mapping[int | str, str] | None = ..., dayfirst: bool = ..., cache_dates: bool = ..., @@ -190,7 +189,6 @@ def read_csv( | Mapping[str, Sequence[int | str]] = ..., infer_datetime_format: bool = ..., keep_date_col: bool = ..., - date_parser: Callable = ..., date_format: str | Mapping[int | str, str] | None = ..., dayfirst: bool = ..., cache_dates: bool = ..., @@ -251,8 +249,7 @@ def read_table( | Mapping[str, Sequence[int | str]] = ..., infer_datetime_format: bool = ..., keep_date_col: bool = ..., - date_parser: Callable = ..., - date_format: str | None = ..., + date_format: dict[Hashable, str] | str | None = ..., dayfirst: bool = ..., cache_dates: bool = ..., iterator: Literal[True], @@ -311,8 +308,7 @@ def read_table( | Mapping[str, Sequence[int | str]] = ..., infer_datetime_format: bool = ..., keep_date_col: bool = ..., - date_parser: Callable = ..., - date_format: str | None = ..., + date_format: dict[Hashable, str] | str | None = ..., dayfirst: bool = ..., cache_dates: bool = ..., iterator: bool = ..., @@ -371,7 +367,6 @@ def read_table( | Mapping[str, Sequence[int | str]] = ..., infer_datetime_format: bool = ..., keep_date_col: bool = ..., - date_parser: Callable = ..., date_format: str | None = ..., dayfirst: bool = ..., cache_dates: bool = ..., @@ -405,7 +400,7 @@ def read_fwf( widths: Sequence[int] | None = ..., infer_nrows: int = ..., dtype_backend: DtypeBackend | NoDefault = ..., - date_format: str | None = ..., + date_format: dict[Hashable, str] | str | None = ..., iterator: Literal[True], chunksize: int | None = ..., **kwds: Any, @@ -418,7 +413,7 @@ def read_fwf( widths: Sequence[int] | None = ..., infer_nrows: int = ..., dtype_backend: DtypeBackend | NoDefault = ..., - date_format: str | None = ..., + date_format: dict[Hashable, str] | str | None = ..., iterator: bool = ..., chunksize: int, **kwds: Any, @@ -431,7 +426,7 @@ def read_fwf( widths: Sequence[int] | None = ..., infer_nrows: int = ..., dtype_backend: DtypeBackend | NoDefault = ..., - date_format: str | None = ..., + date_format: dict[Hashable, str] | str | None = ..., iterator: Literal[False] = ..., chunksize: None = ..., **kwds: Any, diff --git a/tests/test_io.py b/tests/test_io.py index e07cacf5b..adef3d309 100644 --- a/tests/test_io.py +++ b/tests/test_io.py @@ -1409,14 +1409,117 @@ def test_read_sql_dict_str_value_dtype() -> None: def test_added_date_format() -> None: with ensure_clean() as path: - DF.to_string(path, index=False) - check(assert_type(read_fwf(path, date_format="m"), DataFrame), DataFrame) - check(assert_type(read_table(path, date_format="m"), DataFrame), DataFrame) + df_dates = pd.DataFrame( + data={ + "col1": ["2023-03-15", "2023-04-20"], + "col2": ["15-7-2003", "9-12-2000"], + } + ) + df_dates.to_csv(path) + + check( + assert_type( + pd.read_csv(path, parse_dates=["col2"], date_format="%d-%m-%Y"), + pd.DataFrame, + ), + pd.DataFrame, + ) + check( + assert_type( + pd.read_csv( + path, parse_dates=["col2"], date_format={"col2": "%d-%m-%Y"} + ), + pd.DataFrame, + ), + pd.DataFrame, + ) + check( + assert_type( + pd.read_csv(path, parse_dates=["col2"], date_format={10: "%d-%m-%Y"}), + pd.DataFrame, + ), + pd.DataFrame, + ) + check( + assert_type( + pd.read_csv(path, parse_dates=["col1"], date_format="%Y-%m-%d"), + pd.DataFrame, + ), + pd.DataFrame, + ) + check( + assert_type( + pd.read_csv( + path, parse_dates=["col1"], date_format={"col1": "%Y-%m-%d"} + ), + pd.DataFrame, + ), + pd.DataFrame, + ) + check( + assert_type( + pd.read_csv(path, parse_dates=["col1"], date_format={10: "%Y-%m-%d"}), + pd.DataFrame, + ), + pd.DataFrame, + ) + + check( + assert_type( + pd.read_fwf(path, parse_dates=["col1"], date_format="%Y-%m-%d"), + pd.DataFrame, + ), + pd.DataFrame, + ) + check( + assert_type( + pd.read_fwf( + path, parse_dates=["col2"], date_format={"col2": "%d-%m-%Y"} + ), + pd.DataFrame, + ), + pd.DataFrame, + ) + check( + assert_type( + pd.read_fwf(path, parse_dates=["col2"], date_format={10: "%d-%m-%Y"}), + pd.DataFrame, + ), + pd.DataFrame, + ) with ensure_clean(".xlsx") as path: check( - assert_type(pd.DataFrame({"A": [1, 2, 3]}).to_excel(path), None), type(None) + assert_type( + pd.DataFrame( + data={ + "col1": ["2023-03-15", "2023-04-20"], + "col2": ["15-7-2003", "9-12-2000"], + } + ).to_excel(path), + None, + ), + type(None), + ) + check( + assert_type( + pd.read_excel(path, parse_dates=["col2"], date_format={10: "%d-%m-%Y"}), + pd.DataFrame, + ), + pd.DataFrame, + ) + check( + assert_type( + pd.read_excel( + path, parse_dates=["col1"], date_format={"col1": "%Y-%m-%d"} + ), + pd.DataFrame, + ), + pd.DataFrame, ) check( - assert_type(pd.read_excel(path, date_format={9: "row"}), pd.DataFrame), + assert_type( + pd.read_excel(path, parse_dates=["col1"], date_format="%Y-%m-%d"), + pd.DataFrame, + ), pd.DataFrame, ) From 59b2fd3104a6e2f4d9543ff4cd592d9ef830dc1b Mon Sep 17 00:00:00 2001 From: ramvikrams Date: Thu, 18 May 2023 13:25:22 +0530 Subject: [PATCH 7/9] Update test_io.py --- tests/test_io.py | 31 +++---------------------------- 1 file changed, 3 insertions(+), 28 deletions(-) diff --git a/tests/test_io.py b/tests/test_io.py index adef3d309..09e9ec19f 100644 --- a/tests/test_io.py +++ b/tests/test_io.py @@ -1412,34 +1412,10 @@ def test_added_date_format() -> None: df_dates = pd.DataFrame( data={ "col1": ["2023-03-15", "2023-04-20"], - "col2": ["15-7-2003", "9-12-2000"], } ) df_dates.to_csv(path) - check( - assert_type( - pd.read_csv(path, parse_dates=["col2"], date_format="%d-%m-%Y"), - pd.DataFrame, - ), - pd.DataFrame, - ) - check( - assert_type( - pd.read_csv( - path, parse_dates=["col2"], date_format={"col2": "%d-%m-%Y"} - ), - pd.DataFrame, - ), - pd.DataFrame, - ) - check( - assert_type( - pd.read_csv(path, parse_dates=["col2"], date_format={10: "%d-%m-%Y"}), - pd.DataFrame, - ), - pd.DataFrame, - ) check( assert_type( pd.read_csv(path, parse_dates=["col1"], date_format="%Y-%m-%d"), @@ -1474,7 +1450,7 @@ def test_added_date_format() -> None: check( assert_type( pd.read_fwf( - path, parse_dates=["col2"], date_format={"col2": "%d-%m-%Y"} + path, parse_dates=["col1"], date_format={"col1": "%Y-%m-%d"} ), pd.DataFrame, ), @@ -1482,7 +1458,7 @@ def test_added_date_format() -> None: ) check( assert_type( - pd.read_fwf(path, parse_dates=["col2"], date_format={10: "%d-%m-%Y"}), + pd.read_fwf(path, parse_dates=["col1"], date_format={10: "%Y-%m-%d"}), pd.DataFrame, ), pd.DataFrame, @@ -1493,7 +1469,6 @@ def test_added_date_format() -> None: pd.DataFrame( data={ "col1": ["2023-03-15", "2023-04-20"], - "col2": ["15-7-2003", "9-12-2000"], } ).to_excel(path), None, @@ -1502,7 +1477,7 @@ def test_added_date_format() -> None: ) check( assert_type( - pd.read_excel(path, parse_dates=["col2"], date_format={10: "%d-%m-%Y"}), + pd.read_excel(path, parse_dates=["col1"], date_format={10:"%Y-%m-%d"}), pd.DataFrame, ), pd.DataFrame, From 3304f586870d5f60ffe1705ac7c19c2a0af95b12 Mon Sep 17 00:00:00 2001 From: ramvikrams Date: Thu, 18 May 2023 13:27:39 +0530 Subject: [PATCH 8/9] Update test_io.py --- tests/test_io.py | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/tests/test_io.py b/tests/test_io.py index 09e9ec19f..50a7bf02e 100644 --- a/tests/test_io.py +++ b/tests/test_io.py @@ -1442,23 +1442,21 @@ def test_added_date_format() -> None: check( assert_type( - pd.read_fwf(path, parse_dates=["col1"], date_format="%Y-%m-%d"), + pd.read_fwf(path, date_format="%Y-%m-%d"), pd.DataFrame, ), pd.DataFrame, ) check( assert_type( - pd.read_fwf( - path, parse_dates=["col1"], date_format={"col1": "%Y-%m-%d"} - ), + pd.read_fwf(path, date_format={"col1": "%Y-%m-%d"}), pd.DataFrame, ), pd.DataFrame, ) check( assert_type( - pd.read_fwf(path, parse_dates=["col1"], date_format={10: "%Y-%m-%d"}), + pd.read_fwf(path, date_format={10: "%Y-%m-%d"}), pd.DataFrame, ), pd.DataFrame, @@ -1477,7 +1475,7 @@ def test_added_date_format() -> None: ) check( assert_type( - pd.read_excel(path, parse_dates=["col1"], date_format={10:"%Y-%m-%d"}), + pd.read_excel(path, parse_dates=["col1"], date_format={10: "%Y-%m-%d"}), pd.DataFrame, ), pd.DataFrame, From 6ace0abc16d7ac3bc59a04cd475de77d92463b92 Mon Sep 17 00:00:00 2001 From: ramvikrams Date: Thu, 18 May 2023 22:03:09 +0530 Subject: [PATCH 9/9] made `date_format` consistent and changed the tests --- pandas-stubs/io/parsers/readers.pyi | 8 ++++---- tests/test_io.py | 19 +++++++++++++------ 2 files changed, 17 insertions(+), 10 deletions(-) diff --git a/pandas-stubs/io/parsers/readers.pyi b/pandas-stubs/io/parsers/readers.pyi index d669f6353..e25a96be8 100644 --- a/pandas-stubs/io/parsers/readers.pyi +++ b/pandas-stubs/io/parsers/readers.pyi @@ -69,7 +69,7 @@ def read_csv( | Mapping[str, Sequence[int | str]] = ..., infer_datetime_format: bool = ..., keep_date_col: bool = ..., - date_format: str | Mapping[int | str, str] | None = ..., + date_format: dict[Hashable, str] | str | None = ..., dayfirst: bool = ..., cache_dates: bool = ..., iterator: Literal[True], @@ -129,7 +129,7 @@ def read_csv( | Mapping[str, Sequence[int | str]] = ..., infer_datetime_format: bool = ..., keep_date_col: bool = ..., - date_format: str | Mapping[int | str, str] | None = ..., + date_format: dict[Hashable, str] | str | None = ..., dayfirst: bool = ..., cache_dates: bool = ..., iterator: bool = ..., @@ -189,7 +189,7 @@ def read_csv( | Mapping[str, Sequence[int | str]] = ..., infer_datetime_format: bool = ..., keep_date_col: bool = ..., - date_format: str | Mapping[int | str, str] | None = ..., + date_format: dict[Hashable, str] | str | None = ..., dayfirst: bool = ..., cache_dates: bool = ..., iterator: Literal[False] = ..., @@ -367,7 +367,7 @@ def read_table( | Mapping[str, Sequence[int | str]] = ..., infer_datetime_format: bool = ..., keep_date_col: bool = ..., - date_format: str | None = ..., + date_format: dict[Hashable, str] | str | None = ..., dayfirst: bool = ..., cache_dates: bool = ..., iterator: Literal[False] = ..., diff --git a/tests/test_io.py b/tests/test_io.py index 50a7bf02e..8044a79c5 100644 --- a/tests/test_io.py +++ b/tests/test_io.py @@ -1418,15 +1418,20 @@ def test_added_date_format() -> None: check( assert_type( - pd.read_csv(path, parse_dates=["col1"], date_format="%Y-%m-%d"), + pd.read_table( + path, sep=",", parse_dates=["col1"], date_format="%Y-%m-%d" + ), pd.DataFrame, ), pd.DataFrame, ) check( assert_type( - pd.read_csv( - path, parse_dates=["col1"], date_format={"col1": "%Y-%m-%d"} + pd.read_table( + path, + sep=",", + parse_dates=["col1"], + date_format={"col1": "%Y-%m-%d"}, ), pd.DataFrame, ), @@ -1434,7 +1439,9 @@ def test_added_date_format() -> None: ) check( assert_type( - pd.read_csv(path, parse_dates=["col1"], date_format={10: "%Y-%m-%d"}), + pd.read_table( + path, sep=",", parse_dates=["col1"], date_format={0: "%Y-%m-%d"} + ), pd.DataFrame, ), pd.DataFrame, @@ -1456,7 +1463,7 @@ def test_added_date_format() -> None: ) check( assert_type( - pd.read_fwf(path, date_format={10: "%Y-%m-%d"}), + pd.read_fwf(path, date_format={0: "%Y-%m-%d"}), pd.DataFrame, ), pd.DataFrame, @@ -1475,7 +1482,7 @@ def test_added_date_format() -> None: ) check( assert_type( - pd.read_excel(path, parse_dates=["col1"], date_format={10: "%Y-%m-%d"}), + pd.read_excel(path, parse_dates=["col1"], date_format={0: "%Y-%m-%d"}), pd.DataFrame, ), pd.DataFrame,