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

to_period is dropping timezone information #21333

Closed
mungojam opened this issue Jun 5, 2018 · 4 comments · Fixed by #22549
Closed

to_period is dropping timezone information #21333

mungojam opened this issue Jun 5, 2018 · 4 comments · Fixed by #22549
Labels
Datetime Datetime data dtype Period Period data type
Milestone

Comments

@mungojam
Copy link

mungojam commented Jun 5, 2018

localSeries = pd.date_range("2018-7-1", periods=1, freq="30T", tz="Europe/London")
print(localSeries.to_period("30T")[0].start_time)
#Timestamp('2018-07-01 00:00:00')
print(localSeries.to_period("30T")[0].start_time.tz)
#None
print(localSeries.to_period("30T")[0].end_time.tz)
#None
print(localSeries[0].tz)
#<DstTzInfo 'Europe/London' BST+1:00:00 DST>

While this may be useful for monthly/quarterly granularity data, it causes a problem for half-hourly data or similar around clock change, because the local times are used but the time-zone knowledge is dropped without warning.

@gfyoung gfyoung added Datetime Datetime data dtype Period Period data type labels Jun 6, 2018
@gfyoung
Copy link
Member

gfyoung commented Jun 6, 2018

In general, it seems that timezone is dropped, even when you just instantiate a PeriodIndex. Not certain if that's by design. If I piggy-back off your example:

pd.PeriodIndex([localSeries[0]], freq="30T")[0].start_time.tz
# None

cc @jreback @jorisvandenbossche

@jbrockmendel
Copy link
Member

Duplicate of #1159?

@gfyoung
Copy link
Member

gfyoung commented Jul 7, 2018

@jbrockmendel : Seems to be, but I don't see why we give it another shot, since this time it's end-users expressing interest. 🙂

@mungojam
Copy link
Author

mungojam commented Jul 7, 2018

While full timezone support would be nice, the bigger issue for us was the silent dropping of them.

Everywhere else I've seen in Pandas timezones are treated very safely

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

Successfully merging a pull request may close this issue.

4 participants