DatetimeIndex.to_period with freq · Issue #33358 · pandas-dev/pandas (original) (raw)


Code Sample

Input date range:

pi5m = pd.date_range(start='2019-12-22 06:40:00+00:00', end='2019-12-22 08:45:00+00:00', freq='5min')

Converting to PeriodIndex

pi5m.to_period()

File "/home/p/.local/lib/python3.7/site-packages/pandas/core/arrays/period.py", line 938, in dt64arr_to_periodarr freq = Period._maybe_convert_freq(freq)

File "pandas/_libs/tslibs/period.pyx", line 1580, in pandas._libs.tslibs.period._Period._maybe_convert_freq

AttributeError: 'NoneType' object has no attribute 'n'

Working

pi5m.to_period('5min')

Problem description

It is specified in documentation that if not provided, freq is inferred.
However, with above-provided input, I get the error message indicated.
Is this a bug?

Thanks for your feedback.
Bests,