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

BUG: resample with TimedeltaIndex, fenceposts are off #13022

Closed
jreback opened this issue Apr 28, 2016 · 3 comments

Comments

Projects
None yet
3 participants
@jreback
Copy link
Contributor

commented Apr 28, 2016

brought up in #12925
some examples in #15167

Resampling fence posts are off when upsampling < 1 Day.

In [5]: df = DataFrame(data=[[1, 3], [-5, 10], [0, 0]],index=pd.timedelta_range('00:00:00','00:10:00',freq='5T'))

In [6]: df.resample('1T').asfreq()
Out[6]: 
            0     1
00:00:00  1.0   3.0
00:01:00  NaN   NaN
00:02:00  NaN   NaN
00:03:00  NaN   NaN
00:04:00  NaN   NaN
00:05:00 -5.0  10.0
00:06:00  NaN   NaN
00:07:00  NaN   NaN
00:08:00  NaN   NaN
00:09:00  NaN   NaN

In [8]: df.resample('1T').mean()
Out[8]: 
            0     1
00:00:00  1.0   3.0
00:01:00  NaN   NaN
00:02:00  NaN   NaN
00:03:00  NaN   NaN
00:04:00  NaN   NaN
00:05:00 -5.0  10.0
00:06:00  NaN   NaN
00:07:00  NaN   NaN
00:08:00  NaN   NaN
00:09:00  NaN   NaN
00:10:00  0.0   0.0
@jorisvandenbossche

This comment has been minimized.

Copy link
Member

commented Apr 29, 2016

Isn't this the same as #12926, which you fixed already?

@jreback

This comment has been minimized.

Copy link
Contributor Author

commented Apr 29, 2016

very similar, but this test case fails as my original soln didn't work.

@wcwagner

This comment has been minimized.

Copy link
Contributor

commented Aug 8, 2016

Same issue appears when downsampling:

In [6]: from pandas import *
In [7]: rng = timedelta_range(start='1d', periods=10, freq='d')
In [8]: df = DataFrame({'value':range(10)}, index=rng)
In [9]: df.resample('2D').count()
Out[9]: 
         value
1 days       2
3 days       2
5 days       2
7 days       2
9 days       2
11 days      0

In [10]: df.resample('2D').asfreq()
Out[10]: 
        value
1 days      0
3 days      2
5 days      4
7 days      6
9 days      8
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.