-
-
Notifications
You must be signed in to change notification settings - Fork 18.3k
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
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 |
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 |
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. |
…ano as period Closes pandas-dev#12037 Author: Bran Yang <[email protected]> Closes pandas-dev#12270 from BranYang/nanosec and squashes the following commits: bff0c85 [Bran Yang] Add to whatsnew and some comments fd0b307 [Bran Yang] Fix pandas-dev#12037 Error when Resampling using pd.tseries.offsets.Nano as period
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:
The text was updated successfully, but these errors were encountered: