Join GitHub today
GitHub is home to over 20 million developers working together to host and review code, manage projects, and build software together.
ValueError: Values falls after last bin when Resampling using pd.tseries.offsets.Nano as period #12037
Comments
|
xref #9119 does look buggy. can you post an easily reproducible/simpler example that can be easily copy-pasted |
jreback
added Bug Resample Difficulty Intermediate Effort Medium
labels
Jan 14, 2016
jreback
added this to the
Next Major Release
milestone
Jan 14, 2016
nothinkelse
commented
Jan 14, 2016
|
Here is reproducible/simpler example: running in ipython notebook and python 2
Output:
|
|
The issue is caused by line 164, 165 in pandas/tseries/resample.py binner = labels = DatetimeIndex(freq=self.freq,
start=first.replace(tzinfo=None),
# replace will truncate to millisecond
end=last.replace(tzinfo=None),
tz=tz,
name=ax.name)Consider this example In [1]: import pandas as pd
In [2]: from pandas.tseries.index import DatetimeIndex
In [3]: s_ns = 1443707950041939524
In [4]: itvl = 10**9
In [5]: e_ns = s_ns + itvl
In [6]: s = pd.Timestamp(s_ns).tz_localize(None)
In [7]: e = pd.Timestamp(e_ns).tz_localize(None)
In [8]: e
Out[8]: Timestamp('2015-10-01 13:59:11.041939524')
In [9]: indx = DatetimeIndex(freq=pd.tseries.offsets.Nano(itvl/20),start=s, end=
e,tz=None)
In [10]: indx[-1]
Out[10]: Timestamp('2015-10-01 13:59:11.041939524', offset='50000000N')
In [11]: replaced = DatetimeIndex(freq=pd.tseries.offsets.Nano(itvl/20),start=s.
replace(tzinfo=None), end=e.replace(tzinfo=None),tz=None)
In [12]: replaced[-1]
Out[12]: Timestamp('2015-10-01 13:59:11.041939', offset='50000000N')The last item clearly out of the bound if using replace. |
|
@BranYang hmm, that does look likely.
What you need to do is fix that as I believe this is a symptom of an invalid replace. want to take a crack at it? looking |
jreback
added the
Timeseries
label
Jan 20, 2016
|
a couple of other issues might be showing similar symtoms, e.g. #6085 (and linked from there). If this proves to fix, we will want to add tests for those as well. |
BranYang
referenced
this issue
Feb 9, 2016
Closed
Fix #12037 Error when Resampling using pd.tseries.offsets.Nano as period #12270
BranYang
added a commit
to BranYang/pandas
that referenced
this issue
Feb 10, 2016
|
|
BranYang |
fd0b307
|
jreback
closed this
in ab29f93
Feb 10, 2016
cldy
added a commit
to cldy/pandas
that referenced
this issue
Feb 11, 2016
|
|
BranYang + cldy |
74c8344
|
nothinkelse commentedJan 14, 2016
I have a timeseries in dataframe named dfi with non-eqispaced times as index
Output:
I get an error when running this code:
Output + error:
packages versions:
Output: