Skip to content

set_index/reindex bugs with time indices #6631

Closed
@jseabold

Description

@jseabold
[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()

Metadata

Metadata

Assignees

No one assigned

    Labels

    BugDtype ConversionsUnexpected or buggy dtype conversionsPeriodPeriod data type

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions