pandas.
Grouper
A Grouper allows the user to specify a groupby instruction for an object.
This specification will select a column via the key parameter, or if the level and/or axis parameters are given, a level of the index of the target object.
If axis and/or level are passed as keywords to both Grouper and groupby, the values passed to Grouper take precedence.
Groupby key, which selects the grouping column of the target.
The level for the target index.
This will groupby the specified frequency if the target selection (via key or level) is a datetime-like object. For full specification of available frequencies, please see here.
Number/name of the axis.
Whether to sort the resulting labels.
Closed end of interval. Only when freq parameter is passed.
Interval boundary to use for labeling. Only when freq parameter is passed.
If grouper is PeriodIndex and freq parameter is passed.
Only when freq parameter is passed.
Examples
Syntactic sugar for df.groupby('A')
df.groupby('A')
>>> df.groupby(Grouper(key='A'))
Specify a resample operation on the column ‘date’
>>> df.groupby(Grouper(key='date', freq='60s'))
Specify a resample operation on the level ‘date’ on the columns axis with a frequency of 60s
>>> df.groupby(Grouper(level='date', freq='60s', axis=1))
Attributes
ax
groups