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
In [13]: df = pd.DataFrame({'date': pd.date_range('2015-01-01', freq='W', periods=5),
'a': np.arange(5)},
index=pd.MultiIndex.from_arrays([
[1,2,3,4,5],
pd.date_range('2015-01-01', freq='W', periods=5)],
names=['v','d']))
In [14]: df
Out[14]:
a date
v d
1 2015-01-04 0 2015-01-04
2 2015-01-11 1 2015-01-11
3 2015-01-18 2 2015-01-18
4 2015-01-25 3 2015-01-25
5 2015-02-01 4 2015-02-01
Right now to resample by MultiIndex level 'd' or column 'date' it would be:
In [15]: df.groupby(pd.TimeGrouper(key='date', freq='M')).sum()
Out[15]:
a
date
2015-01-31 6
2015-02-28 4
In [16]: df.groupby(pd.TimeGrouper(level='d', freq='M')).sum()
Out[16]: <same>
What if we instead allowed this as a convenience?
In [17]: df.resample('M', level='d').sum()
In [17]: df.resample('M', key='date').sum()
The text was updated successfully, but these errors were encountered:
Idea after seeing the gitter between @ssanderson and @jorisvandenbossche
Consider this data:
Right now to resample by
MultiIndex
level'd'
or column'date'
it would be:What if we instead allowed this as a convenience?
The text was updated successfully, but these errors were encountered: