Open joooeey opened 2 years ago
Thanks @joooeey for the report.
Expected Behavior
The good option, analogous to
DatetimeIndex
:
- Whenever a
PeriodIndex
is created with all arguments in the same time-zone like in the example above, the resultingPeriodIndex
acquires that time zone.
There is quite some discussion in #45736 regarding supporting timezone-aware Period.
- The lazy option, which I consider urgent to implement: Whenever a
PeriodIndex
is created with at least one time-zone aware argument, a warning is raised saying that the result will be time-zone naive. This is crucial to avoid bugs. Note Whatever solution we go with, this should be fixed in the constructor ofPeriodIndex
not further up inpd.period_range
,Timestamp.to_period
or similar.
To avoid duplicating discussion in more than one place, this issue could be left open if we consider this the way forward to close this issue.
Pandas version checks
[X] I have checked that this issue has not already been reported.
[X] I have confirmed this bug exists on the latest version of pandas.
[X] I have confirmed this bug exists on the main branch of pandas.
Reproducible Example
Issue Description
Creating a
PeriodIndex
withpd.period_range
with timezone-aware inputs creates a timezone-naivePeriodIndex
without even emmitting a warning that the timezone is dropped.This appears to have the same root cause as #28039 and #21333. There is a fix for #21333 in #22549 (i.e. we warn now) but to me that seems too far upstream. This needs to be fixed in the
PeriodIndex
constructor.Expected Behavior
The good option, analogous to
DatetimeIndex
:PeriodIndex
is created with all arguments in the same time-zone like in the example above, the resultingPeriodIndex
acquires that time zone.PeriodIndex
will be time-zone naive too.PeriodIndex
is created with at least one time-zone aware argument, a warning is raised saying that the result will be time-zone naive. This is crucial to avoid bugs. Note Whatever solution we go with, this should be fixed in the constructor ofPeriodIndex
not further up inpd.period_range
,Timestamp.to_period
or similar.Installed Versions