New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ENH: Allow period_range to accept freq with mult != 1 #7811

Closed
sinhrks opened this Issue Jul 20, 2014 · 1 comment

Comments

Projects
None yet
2 participants
@sinhrks
Member

sinhrks commented Jul 20, 2014

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
@jreback

This comment has been minimized.

Show comment
Hide comment
@jreback

jreback Jul 21, 2014

Contributor

I seem to remember an issue looking at this ? can you check

Contributor

jreback commented Jul 21, 2014

I seem to remember an issue looking at this ? can you check

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment