BUG: infer_freq
throws exception on Series
of timezone-aware Timestamp
s
#52456
Labels
infer_freq
throws exception on Series
of timezone-aware Timestamp
s
#52456
Pandas version checks
I have checked that this issue has not already been reported.
I have confirmed this bug exists on the latest version of pandas.
I have confirmed this bug exists on the main branch of pandas.
Reproducible Example
Issue Description
When given a
Series
of timezone-awareTimestamp
s,infer_freq
throws an exception. However, if given aDatetimeIndex
of the exact same sequence of timezone-awareTimestamp
s, it works just fine. The problem comes from thatDatetimeTZDtype
is not allowed when checking thedtype
of theSeries
. Addingis_datetime64tz_dtype
to thedtype
check should fix this issue.pandas/pandas/tseries/frequencies.py
Lines 151 to 159 in 8daf188
Note that, although the documentation says the input type must be
DatetimeIndex
orTimedeltaIndex
, the type annotation does includeSeries
. The discrepancy among documentation, type annotation, and implementation (which acceptsSeries
and converts it intoDatetimeIndex
when possible) should also be fixed.pandas/pandas/tseries/frequencies.py
Lines 115 to 117 in 8daf188
Actual output of the example:
Expected Behavior
infer_freq
should acceptSeries
of timezone-aware timestamps, convert it intoDateTimeIndex
, and proceed as usual.Installed Versions
The text was updated successfully, but these errors were encountered: