Skip to content
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

ENH: Add support for more placeholders in guess_datetime_format #43901

Closed
davesque opened this issue Oct 6, 2021 · 0 comments · Fixed by #43900
Closed

ENH: Add support for more placeholders in guess_datetime_format #43901

davesque opened this issue Oct 6, 2021 · 0 comments · Fixed by #43900
Labels
Datetime Datetime data dtype Enhancement
Milestone

Comments

@davesque
Copy link
Contributor

davesque commented Oct 6, 2021

Is your feature request related to a problem?

We recently realized that pandas.core.tools.datetimes.guess_datetime_format outputs an incorrect format string "Tue %d %b %Y %H:%M:%S AM" for the datetime "Tue 24 Aug 2021 01:30:48 AM", which otherwise is parseable by dateutil.parser.parse.

Describe the solution you'd like

Since "Tue 24 Aug 2021 01:30:48 AM" is parseable by dateutil.parser.parse and guess_datetime_format is based on that function, it seems reasonable that guess_datetime_format should produce a correct format string when given this example datetime.

API breaking implications

I believe modifying guess_datetime_format to support more formats placeholders should be a backwards compatible change.

Describe alternatives you've considered

Not sure that there are any.

Additional context

from pandas.core.tools.datetimes import guess_datetime_format

# actual
assert guess_datetime_format("Tue 24 Aug 2021 01:30:48 AM") == "Tue %d %b %Y %H:%M:%S AM"

# expected
assert guess_datetime_format("Tue 24 Aug 2021 01:30:48 AM") == "%a %d %b %Y %H:%M:%S %p"

I already have a PR up for this here: #43900

@davesque davesque added Enhancement Needs Triage Issue that has not been reviewed by a pandas team member labels Oct 6, 2021
davesque added a commit to davesque/pandas that referenced this issue Oct 6, 2021
…ndas-dev#43901)

Add support for day of week and meridiem placeholders and any
combination of placeholders supported by `strftime` that do not
correspond to a datetime attribute.
davesque added a commit to davesque/pandas that referenced this issue Oct 6, 2021
…ndas-dev#43901)

Add support for day of week and meridiem placeholders and any
combination of placeholders supported by `strftime` that do not
correspond to a datetime attribute.
@jreback jreback added Datetime Datetime data dtype and removed Needs Triage Issue that has not been reviewed by a pandas team member labels Oct 6, 2021
@jreback jreback added this to the 1.4 milestone Oct 6, 2021
davesque added a commit to davesque/pandas that referenced this issue Oct 7, 2021
…ndas-dev#43901)

Add support for day of week and meridiem placeholders and any
combination of placeholders supported by `strftime` that do not
correspond to a datetime attribute.
mroeschke pushed a commit that referenced this issue Oct 17, 2021
…3901) (#43900)

Add support for day of week and meridiem placeholders and any
combination of placeholders supported by `strftime` that do not
correspond to a datetime attribute.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Datetime Datetime data dtype Enhancement
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants