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

Comments

Projects
None yet
4 participants
@mungojam
Copy link

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

This comment has been minimized.

Copy link
Member

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

This comment has been minimized.

Copy link
Member

commented Jul 7, 2018

Duplicate of #1159?

@gfyoung

This comment has been minimized.

Copy link
Member

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

This comment has been minimized.

Copy link
Author

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
You can’t perform that action at this time.