Skip to content

infer_freq borks on PeriodIndex #5841

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

Closed
jseabold opened this issue Jan 3, 2014 · 3 comments · Fixed by #5847
Closed

infer_freq borks on PeriodIndex #5841

jseabold opened this issue Jan 3, 2014 · 3 comments · Fixed by #5847
Labels
Error Reporting Incorrect or improved errors from pandas Period Period data type
Milestone

Comments

@jseabold
Copy link
Contributor

jseabold commented Jan 3, 2014

Should PeriodIndex pass through infer_freq and return freqstr or should this be the user's problem? Either is a simple fix. The latter should just have a better error message. Right now

from pandas.tseries.api import infer_freq
from pandas import PeriodIndex

infer_freq(PeriodIndex(start="1/1/1990", periods=20, freq="M"))
@jreback
Copy link
Contributor

jreback commented Jan 3, 2014

inferring is not implemented for PeriodIndex AFAICT

In [11]: p = PeriodIndex(start="1/1/1990", periods=20, freq="M")

In [12]: p.freqstr
Out[12]: 'M'

In [13]: p.freq
Out[13]: 'M'

@jseabold
Copy link
Contributor Author

jseabold commented Jan 3, 2014

Yes. Should it be? I.e., trivially return freqstr since you don't need to do any inferring or have a better error message than the one about converting Int64Index to Datetime. Use case is for time series models in statsmodels. Should we handle it or should infer_freq handle it? (I've already committed a fix, so I don't really care either way.)

@jreback
Copy link
Contributor

jreback commented Jan 3, 2014

I think the use would be if someone puts together multiple Periods and tries to create a PeriodIndex

But I don't think very comment (unlike doing this with Timestamps, which is pretty common)

and unless they are ALL the same freq it would bork anyhow.

So maybe just a better error message.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Error Reporting Incorrect or improved errors from pandas Period Period data type
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants