- 
          
 - 
                Notifications
    
You must be signed in to change notification settings  - Fork 19.2k
 
Closed
Labels
Milestone
Description
date_range can accept freq with mult != 1 and output DatetimeIndex, otherwise period_range raises ValueError.
pd.date_range('2014-01-01 09:00', '2014-01-01 20:00', freq='4H')
# <class 'pandas.tseries.index.DatetimeIndex'>
# [2014-01-01 09:00:00, ..., 2014-01-01 21:00:00]
# Length: 4, Freq: 4H, Timezone: None
pd.date_range('2014-01-01 20:00', '2014-01-01 09:00', freq='-1H')
# <class 'pandas.tseries.index.DatetimeIndex'>
# [2014-01-01 20:00:00, ..., 2014-01-01 09:00:00]
# Length: 12, Freq: -1H, Timezone: None
pd.period_range('2014-01-01 09:00', '2014-01-01 20:00', freq='4H')
# ValueError: Only mult == 1 supported
Is it reasonable to accept period_range and PeriodIndex.__new__ to this kind of freq? What I want to do is creating skipped or reversed ordered PeriodIndex easily.
(Considering internal representation of PeriodIndex, it looks better to result have normal freq,  not to add numberized-freq like 4H).
Expected
pd.period_range('2014-01-01 09:00', '2014-01-01 20:00', freq='4H')
# <class 'pandas.tseries.period.PeriodIndex'>
# [2014-01-01 09:00:00, ..., 2014-01-01 21:00:00]
# Length: 4, Freq: H
pd.period_range('2014-01-01 20:00', '2014-01-01 09:00', freq='-1H')
# <class 'pandas.tseries.period.PeriodIndex'>
# [2014-01-01 20:00:00, ..., 2014-01-01 09:00:00]
# Length: 12, Freq: H