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

Resampling fails with equal frequency #12072

Closed
richjoyce opened this issue Jan 17, 2016 · 1 comment
Closed

Resampling fails with equal frequency #12072

richjoyce opened this issue Jan 17, 2016 · 1 comment
Labels
Bug Resample resample method
Milestone

Comments

@richjoyce
Copy link

I've got a DataFrame with a TimedeltaIndex that fails when I try to resample it to the same frequency.

Minimal working example

import pandas as pd
index = pd.timedelta_range('0', periods=9, freq='10L')
series = pd.Series(range(9), index=index)
series.resample('10L') # throws ValueError

pandas versions

INSTALLED VERSIONS
------------------
commit: None
python: 2.7.10.final.0
python-bits: 64
OS: Darwin
OS-release: 14.5.0
machine: x86_64
processor: i386
byteorder: little
LC_ALL: None
LANG: en_US.UTF-8

pandas: 0.17.1
nose: None
pip: 1.4.1
setuptools: 1.1.6
Cython: None
numpy: 1.8.0rc1
scipy: 0.13.0b1
statsmodels: None
IPython: 2.0.0
sphinx: 1.2.2
patsy: None
dateutil: 1.5
pytz: 2013.7
blosc: None
bottleneck: None
tables: None
numexpr: 2.4.6
matplotlib: 1.3.1
openpyxl: None
xlrd: None
xlwt: None
xlsxwriter: None
lxml: None
bs4: None
html5lib: None
httplib2: None
apiclient: None
sqlalchemy: None
pymysql: None
psycopg2: None
Jinja2: None

The error thrown is:

pandas/tseries/resample.pyc in _resample_timestamps(self, kind)
    306                     axlabels.inferred_freq) == self.freq:
    307                     result = obj.copy()
--> 308                     result.index = res_index
    309                 else:
    310                     result = obj.reindex(res_index, method=self.fill_method,
... (more stacks skipped) ...
ValueError: Length mismatch: Expected axis has 9 elements, new values have 8 elements

This appears to be a problem with the logic in TimeGrouper._resample_timestamps() lines 298 to 308, the error is being thrown on line 308. It looks like res_index is being set to the wrong thing but I'm not familiar enough with the code to know how to fix properly.

@jreback
Copy link
Contributor

jreback commented Jan 17, 2016

this is fixed in the resample refactor, #11841
but will add as a confirming test.

@jreback jreback added Bug Resample resample method labels Jan 17, 2016
@jreback jreback added this to the 0.18.0 milestone Jan 17, 2016
jreback added a commit to jreback/pandas that referenced this issue Feb 2, 2016
@jreback jreback closed this as completed in 1dc49f5 Feb 2, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug Resample resample method
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants