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
So we want to have some built-in functionality for this?
The example:
import itertools
import pandas as pd
lev1 = ['foo', 'bar', 'baz']
lev2 = list('abc')
n = 6
df = pd.DataFrame({k: np.random.randn(n) for k in itertools.product(lev1,lev2)},
index=pd.DatetimeIndex(start='2015-01-01', periods=n, freq='11D'))
bar baz foo
a b c a b c a b c
2015-01-01 -1.11 2.12 -1.00 0.18 0.14 1.24 0.73 0.06 3.66
2015-01-12 -1.43 0.75 0.38 0.04 -0.33 -0.42 1.00 -1.63 -1.35
2015-01-23 0.01 -1.70 -1.39 0.59 -1.10 -1.17 -1.51 -0.54 -1.11
2015-02-03 0.93 0.70 -0.12 1.07 -0.97 -0.45 -0.19 0.11 -0.79
2015-02-14 0.30 0.49 0.60 -0.28 -0.38 1.11 0.15 0.78 -0.58
2015-02-25 -0.26 0.51 0.82 0.05 -1.45 0.14 0.53 -0.33 -1.35
The question is here if it should be possible in groupby().aggregate() to specify that you want to apply a function to all columns of a certain level label.
E.g. df.groupby(pd.TimeGrouper('MS')).aggregate({'bar': np.sum, 'baz': np.mean, 'foo': np.min}) does not work at the moment.
Or does this lead to far?
The text was updated successfully, but these errors were encountered:
See http://stackoverflow.com/questions/28833074/aggregate-group-with-multi-level-columns
So we want to have some built-in functionality for this?
The example:
The question is here if it should be possible in
groupby().aggregate()
to specify that you want to apply a function to all columns of a certain level label.E.g.
df.groupby(pd.TimeGrouper('MS')).aggregate({'bar': np.sum, 'baz': np.mean, 'foo': np.min})
does not work at the moment.Or does this lead to far?
The text was updated successfully, but these errors were encountered: