Skip to content

BUG: Resample on empty Period-Indexed Series returns Datetime-Indexed Series #12868

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
jduncavage opened this issue Apr 11, 2016 · 5 comments
Closed
Labels
Bug Period Period data type Resample resample method
Milestone

Comments

@jduncavage
Copy link

Code Sample, a copy-pastable example if possible

In [7]: pd.Series([], pd.period_range(start='2000', periods=0)).resample('W').mean().index Out[7]: DatetimeIndex([], dtype='datetime64[ns]', freq='W-SUN')

Expected Output

PeriodIndex([], dtype='int64', freq='W-SUN')

On pandas: 0.18.0

@max-sixty
Copy link
Contributor

@jreback Lots of issues with PeriodIndex & resample. ref: #12774 & #12770

I didn't really follow the resample refactor so I don't know the genesis of these. I had a look through the current code but can't find easy fixes. Looks like a lot is reliant on the kind attribute, but it's not completely consistent (i.e. a resampled PeriodIndex at times changes kind from period to timestamp, etc).

Do you have any ideas for an overarching strategy for these?
For example, should we just convert every PeriodIndex to a DatetimeIndex, resample it, and then convert back?

@jreback
Copy link
Contributor

jreback commented Apr 11, 2016

@MaximilianR I commented on this in #12774 . The logic from < 0.18.0 is exactly the same. The problem is the period is not systematically tested and there are quite a few edge cases. Further compounding this is the kind kw, which I think we could just totally eliminate. Now the obstacle is that its often easier to change the DTI to a PI, resample then change it back. The code paths are there, just the kind thing really perverts the logic.

So what we need is a fair amount of systematic testing. Then remove the kind (well you don't actually remove it, but deprecate it and we'll remove it later).

@jreback
Copy link
Contributor

jreback commented Apr 11, 2016

I'll make a master Period Resample issue I think.

@jreback jreback added this to the Next Major Release milestone Apr 11, 2016
@jreback jreback added the Resample resample method label Apr 11, 2016
@max-sixty
Copy link
Contributor

Now the obstacle is that its often easier to change the DTI to a PI, resample then change it back.

OK - can I confirm that you think this is the best path forward, for all PeriodIndex resampling?

The logic from < 0.18.0 is exactly the same.

OK, these are regressions though (from our unit tests failing on our upgrade)

@jreback
Copy link
Contributor

jreback commented Apr 11, 2016

if u have failing tests then they must be things that are not tested in pandas - nothing regressed AFAICT

@jreback jreback modified the milestones: 0.18.1, Next Major Release Apr 13, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug Period Period data type Resample resample method
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants