Skip to content

DEPR: Resample with PeriodIndex? #53481

Closed
@jbrockmendel

Description

@jbrockmendel

Resampling with PeriodIndex is very very broken:

pi = pd.period_range(start="2000", periods=3, freq="M")
ser= pd.Series(["foo", "bar", "baz"], index=pi)
rs = ser.resample("M")  # should be a no-op!

>>> rs.nunique()
2000-01    foo
2000-02    bar
2000-03    baz
Freq: M, dtype: object

Some of this is because in PeriodIndexResampler._downsample (which many methods go through) we just return self.asfreq() in many cases which is very much wrong. We have some xfailed tests (e.g. test_resample_nat_index_series) that cause this as well as some actively-incorrect tests (e.g. test_resample_empty_dtypes, test_resample_same_freq)

Is this worth fixing or should we just deprecate it?

Metadata

Metadata

Assignees

No one assigned

    Labels

    DeprecateFunctionality to remove in pandasNeeds DiscussionRequires discussion from core team before further actionPeriodPeriod data typeResampleresample method

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions