Skip to content

ENH: Added a new format in parsing.pyx #50523

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

Closed
wants to merge 5 commits into from
Closed
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
1 change: 1 addition & 0 deletions pandas/_libs/tslibs/parsing.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -856,6 +856,7 @@ def guess_datetime_format(dt_str: str, bint dayfirst=False) -> str | None:
(("day_of_week",), "%a", 0),
(("day_of_week",), "%A", 0),
(("meridiem",), "%p", 0),
(("year", "month", "day"), ("hour", "minute", "second"), "%Y%m%d %H%M%S", 0),
]

if dayfirst:
Expand Down
13 changes: 13 additions & 0 deletions pandas/tests/tslibs/test_parsing.py
Original file line number Diff line number Diff line change
Expand Up @@ -332,3 +332,16 @@ def test_guess_datetime_format_f(input):
result = parsing.guess_datetime_format(input)
expected = "%Y-%m-%dT%H:%M:%S.%f"
assert result == expected


@pytest.mark.parametrize(
"input",
[
"20110519 010000",
"20120617 020000",
],
)
def test_guess_datetime_format_iso_new(input):
result = parsing.guess_datetime_format(input)
expected = "%Y%m%d %H%M%S"
assert result == expected