Skip to content

Conversation

@MarcoGorelli
Copy link
Member

@MarcoGorelli MarcoGorelli commented Oct 5, 2022

Haven't added a whatsnew note as this function isn't (yet) user-facing

This extra try-except adds about 9 microseconds on my laptop:

upstream/main:

In [2]: %%timeit
   ...: guess_datetime_format('2020-01-01 00:00:00 UTC+1')
   ...: 
   ...: 
93 µs ± 652 ns per loop (mean ± std. dev. of 7 runs, 10,000 loops each)

this branch:

In [3]: %%timeit
   ...: guess_datetime_format('2020-01-01 00:00:00 UTC+1')
   ...: 
   ...: 
102 µs ± 141 ns per loop (mean ± std. dev. of 7 runs, 10,000 loops each)

IMO this is negligible and worth it

@MarcoGorelli MarcoGorelli added Bug Datetime Datetime data dtype labels Oct 5, 2022
@MarcoGorelli MarcoGorelli requested a review from mroeschke October 5, 2022 18:10
("2011-12-30T00:00:00.000000+09:000", "%Y-%m-%dT%H:%M:%S.%f%z"),
("2011-12-30T00:00:00.000000+9:0", "%Y-%m-%dT%H:%M:%S.%f%z"),
("2011-12-30T00:00:00.000000+09:000", None),
("2011-12-30T00:00:00.000000+9:0", None),
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could you add a comment in the test to note that odd +9 format shouldn't be supported by %z but dateutil.parse can support this format?

Copy link
Member

@mroeschke mroeschke left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just a comment to add a comment otherwise LGTM

@mroeschke mroeschke added this to the 1.6 milestone Oct 5, 2022
@mroeschke mroeschke merged commit f47d82b into pandas-dev:main Oct 5, 2022
@mroeschke
Copy link
Member

Thanks @MarcoGorelli

@mroeschke mroeschke modified the milestones: 1.6, 2.0 Oct 13, 2022
noatamir pushed a commit to noatamir/pandas that referenced this pull request Nov 9, 2022
…andas-dev#48954)

* BUG: guess_datetime_format doesn't guess format correctly for UTC+1

* :doc: add comment on +9 offset

Co-authored-by: MarcoGorelli <>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Bug Datetime Datetime data dtype

Projects

None yet

Development

Successfully merging this pull request may close these issues.

BUG: guess_datetime_format doesn't guess format correctly for UTC+1

2 participants