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

Should DatetimeTZDtype normalize the timezone? #24713

Closed
TomAugspurger opened this issue Jan 10, 2019 · 1 comment · Fixed by #25254
Closed

Should DatetimeTZDtype normalize the timezone? #24713

TomAugspurger opened this issue Jan 10, 2019 · 1 comment · Fixed by #25254
Labels
Timezones Timezone data dtype
Milestone

Comments

@TomAugspurger
Copy link
Contributor

The .tz on a Timestamp can differ from the .tz on the array / index it's contained within

In [5]: idx = pd.date_range('2000', periods=4, tz="US/Central")

In [6]: idx.tz
Out[6]: <DstTzInfo 'US/Central' LMT-1 day, 18:09:00 STD>

In [7]: idx[0].tz
Out[7]: <DstTzInfo 'US/Central' CST-1 day, 18:00:00 STD>

I gather that this is the correct behavior. My question: since DatetimeTZDtype is only really used when attached to an array, should it automatically normalize the user-provided tz to the version that's attached to the array? In code, both of the following

In [11]: pd.DatetimeTZDtype(tz=idx.tz).tz
Out[11]: <DstTzInfo 'US/Central' LMT-1 day, 18:09:00 STD>

In [12]: pd.DatetimeTZDtype(tz=idx[0].tz).tz
Out[12]: <DstTzInfo 'US/Central' CST-1 day, 18:00:00 STD>

would be equal to the normalized version, Out[11].

originally suggested by @jbrockmendel. cc @mroeschke.

@TomAugspurger TomAugspurger added the Timezones Timezone data dtype label Jan 10, 2019
@mroeschke
Copy link
Member

I'm inclined to say yes for the use case of comparing two pd.DatetimeTZDtypes internally(?)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Timezones Timezone data dtype
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants