pandas_extension.TransposedGroupBy

pandas_extension.TransposedGroupBy(self, transposed_groupby)

Same as pandas.DataFrameGroupBy, but returns the transpose of the result.

Useful where a groupby is performed on a transposed DataFrame, and after aggregation the result should be transposed back.

Parameters

Name Type Description Default
transposed_groupby pandas.DataFrameGroupBy A pandas.DataFrameGroupBy object, which is created from a transposed DataFrame. required

Examples

>>> df = res.reaches.read(column_mode='all')
>>> groupby = TransposedGroupBy(df.T.groupby(['quantity]))
>>> groupby.agg(['mean', 'max'])
... # performs agg function, then returns the transpose of the result.