Skip to content
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

set_index/reindex bugs with time indices #6631

Closed
jseabold opened this issue Mar 13, 2014 · 2 comments · Fixed by #7092
Closed

set_index/reindex bugs with time indices #6631

jseabold opened this issue Mar 13, 2014 · 2 comments · Fixed by #7092
Labels
Bug Dtype Conversions Unexpected or buggy dtype conversions Period Period data type
Milestone

Comments

@jseabold
Copy link
Contributor

[14]: pd.version.version
[14]: '0.13.1-426-ge19b2eb'

Noticed these. This one's minor. set_index seems to drop frequency information for DatetimeIndex. I'm not sure what other metadata is ignored.

import statsmodels.api as sm
import pandas as pd
index = pd.PeriodIndex(start='1959Q1', end='2009Q3')
dta = sm.datasets.macrodata.load_pandas().data

assert dta.set_index(index.to_timestamp()).index.freq == index.to_timestamp().freq

This one is less minor. set_index and reindex are broken for a PeriodIndex. Treats it as regular integer index I guess. Not sure if it ever worked, though I don't recall running into this before.

dta.set_index(index).head()

dta.reindex(index).head()
@jreback
Copy link
Contributor

jreback commented Mar 13, 2014

you can just do

dta.index = index

I see where the issue is in set_index, will mark as a bug

@jreback jreback added this to the 0.15.0 milestone Mar 13, 2014
@jseabold
Copy link
Contributor Author

Yeah, that's what I have in all the statsmodels examples, though I thought the setting of the attribute was a no-no (don't recall why though). Just trying to disseminate best practices.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug Dtype Conversions Unexpected or buggy dtype conversions Period Period data type
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants