pandas.Grouper
-
class pandas.Grouper(key=None, level=None, freq=None, axis=0, sort=False)[source] -
A Grouper allows the user to specify a groupby instruction for a target 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.
These are local specifications and will override ‘global’ settings, that is the parameters axis and level which are passed to the groupby itself.
Parameters: -
key : string, defaults to None -
ключ для группировки, который выбирает столбец для группировки целевого объекта
-
level : name/number, defaults to None -
уровень для индекса целевого объекта
-
freq : string / frequency object, defaults to None -
Это будет группировка по указанной частоте, если целевой выбор (через ключ или уровень) — это объект datetime. Для полного описания доступных частот см. здесь.
-
axis : number/name of the axis, defaults to 0 -
sort : boolean, default to False -
сортировать ли результирующие метки
- additional kwargs to control time-like groupers (when `freq` is passed)
-
closed : closed end of interval; ‘left’ or ‘right’ -
label : interval boundary to use for labeling; ‘left’ or ‘right’ -
convention : {‘start’, ‘end’, ‘e’, ‘s’} -
Если grouper — это PeriodIndex
- base, loffset
Returns: - A specification for a groupby instruction
Examples
Syntactic sugar for
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 -
© 2008–2012, AQR Capital Management, LLC, Lambda Foundry, Inc. and PyData Development Team
Licensed under the 3-clause BSD License.
https://pandas.pydata.org/pandas-docs/version/0.24.2/reference/api/pandas.Grouper.html