Skip to content

Resampling with NaT in PeriodIndex raises ValueError #13224

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
evectant opened this issue May 18, 2016 · 1 comment · Fixed by #16153
Closed

Resampling with NaT in PeriodIndex raises ValueError #13224

evectant opened this issue May 18, 2016 · 1 comment · Fixed by #16153
Labels
Period Period data type Resample resample method
Milestone

Comments

@evectant
Copy link
Contributor

PeriodIndex can't handle NaT:

In [2]: pi = pd.PeriodIndex(['1970-01-01 00:00:00', pd.NaT, '1970-01-01 00:00:02'], freq='S')

In [3]: pd.DataFrame([2, 3, 5], pi).resample('1s').mean()
...
ValueError: Start and end must not be NaT

But DatetimeIndex obtained from PeriodIndex can:

In [4]: pd.DataFrame([2, 3, 5], pi.to_datetime()).resample('1s').mean()
Out[4]: 
                       0
1970-01-01 00:00:00  2.0
1970-01-01 00:00:01  NaN
1970-01-01 00:00:02  5.0

Shouldn't these behave the same?

Versions:

python: 2.7.11.final.0
OS: Linux
machine: x86_64
pandas: 0.18.1+38.gc7e6f5f.dirty
numpy: 1.10.2
@jreback jreback added Period Period data type Resample resample method Difficulty Intermediate labels May 18, 2016
@jreback jreback added this to the 0.18.2 milestone May 18, 2016
@jreback
Copy link
Contributor

jreback commented May 18, 2016

added to the PI resample list.

@jorisvandenbossche jorisvandenbossche modified the milestones: Next Major Release, 0.19.0 Aug 21, 2016
@jreback jreback modified the milestones: Next Major Release, 0.21.0 Sep 28, 2017
jreback pushed a commit that referenced this issue Oct 1, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Period Period data type Resample resample method
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants