Skip to content

GH:624- added date_format to read_table,read_fwf and read_excel #695

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 10 commits into from
May 18, 2023
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
Prev Previous commit
made date_format consistent and changed the tests
  • Loading branch information
ramvikrams committed May 18, 2023
commit 6ace0abc16d7ac3bc59a04cd475de77d92463b92
8 changes: 4 additions & 4 deletions pandas-stubs/io/parsers/readers.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -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],
Expand Down Expand Up @@ -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 = ...,
Expand Down Expand Up @@ -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] = ...,
Expand Down Expand Up @@ -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] = ...,
Expand Down
19 changes: 13 additions & 6 deletions tests/test_io.py
Original file line number Diff line number Diff line change
Expand Up @@ -1418,23 +1418,30 @@ 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,
),
pd.DataFrame,
)
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,
Expand All @@ -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,
Expand All @@ -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,
Expand Down