Skip to content

to_period is dropping timezone information #21333

Closed
@mungojam

Description

@mungojam
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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    DatetimeDatetime data dtypePeriodPeriod data type

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions