You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
resample gained a new keyword on to be able to resample based on a column of datetime values instead of the index (which can prevent some use of set_index/reset_index). This feature is however not yet available for resample after a groupby.
Code Sample
In [8]: df = pd.DataFrame({'key': ['A', 'B']*5, 'dates': pd.date_range('2016-01-01', periods=10), 'values': np.random.randn(10)})
In [9]: df
Out[9]:
dates key values
0 2016-01-01 A -1.291535
1 2016-01-02 B 0.922945
2 2016-01-03 A -1.039163
3 2016-01-04 B -1.102022
4 2016-01-05 A 1.220347
5 2016-01-06 B 0.265720
6 2016-01-07 A 0.888080
7 2016-01-08 B -0.250236
8 2016-01-09 A 0.485518
9 2016-01-10 B -0.188880
In [11]: df.set_index('dates').groupby('key').resample('D').mean()
Out[11]:
values
key dates
A 2016-01-01 -1.291535
2016-01-02 NaN
2016-01-03 -1.039163
2016-01-04 NaN
2016-01-05 1.220347
2016-01-06 NaN
2016-01-07 0.888080
2016-01-08 NaN
2016-01-09 0.485518
B 2016-01-02 0.922945
2016-01-03 NaN
2016-01-04 -1.102022
2016-01-05 NaN
2016-01-06 0.265720
2016-01-07 NaN
2016-01-08 -0.250236
2016-01-09 NaN
2016-01-10 -0.188880
In [12]: df.groupby('key').resample('D', on='dates').mean()
...
TypeError: __init__() got an unexpected keyword argument 'on'
Using pandas master, 0.19.0+289.g1bf94c8
The text was updated successfully, but these errors were encountered:
closespandas-dev#15021
Author: Nicholas Ver Halen <[email protected]>
Closespandas-dev#15326 from verhalenn/issue15021 and squashes the following commits:
9fc3b4f [Nicholas Ver Halen] Updated the whatsnew for issue 15021
ec1f316 [Nicholas Ver Halen] Created a test for GH 15021
b8b10b0 [Nicholas Ver Halen] Added the on arg to resample on a grouped dataframe.
Problem description
resample
gained a new keywordon
to be able to resample based on a column of datetime values instead of the index (which can prevent some use ofset_index
/reset_index
). This feature is however not yet available for resample after a groupby.Code Sample
Using pandas master, 0.19.0+289.g1bf94c8
The text was updated successfully, but these errors were encountered: