Skip to content

Commit 98a4b37

Browse files
committed
DOC: update groupby pd.Grouper docs
1 parent 5322695 commit 98a4b37

File tree

4 files changed

+24
-11
lines changed

4 files changed

+24
-11
lines changed

doc/source/api.rst

+1
Original file line numberDiff line numberDiff line change
@@ -1193,6 +1193,7 @@ Indexing, iteration
11931193
GroupBy.groups
11941194
GroupBy.indices
11951195
GroupBy.get_group
1196+
Grouper
11961197

11971198
Function application
11981199
~~~~~~~~~~~~~~~~~~~~

doc/source/release.rst

+1-1
Original file line numberDiff line numberDiff line change
@@ -132,7 +132,7 @@ API Changes
132132
``FutureWarning`` is raised to alert that the old ``rows`` and ``cols`` arguments
133133
will not be supported in a future release (:issue:`5505`)
134134

135-
- Allow specification of a more complex groupby, via ``pd.Groupby`` (:issue:`3794`)
135+
- Allow specification of a more complex groupby, via ``pd.Grouper`` (:issue:`3794`)
136136

137137
- A tuple passed to ``DataFame.sort_index`` will be interpreted as the levels of
138138
the index, rather than requiring a list of tuple (:issue:`4370`)

doc/source/v0.14.0.txt

+1-1
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,7 @@ These are out-of-bounds selections
9494

9595
g.nth(0, dropna='any') # similar to old behaviour
9696

97-
- Allow specification of a more complex groupby via ``pd.Groupby``, such as grouping
97+
- Allow specification of a more complex groupby via ``pd.Grouper``, such as grouping
9898
by a Time and a string field simultaneously. See :ref:`the docs <groupby.specify>`. (:issue:`3794`)
9999

100100
- Local variable usage has changed in

pandas/core/groupby.py

+21-9
Original file line numberDiff line numberDiff line change
@@ -141,25 +141,37 @@ def _last(x):
141141

142142
class Grouper(object):
143143
"""
144-
A Grouper allows the user to specify a groupby instruction
144+
A Grouper allows the user to specify a groupby instruction for a target object
145+
146+
This specification will select a column via the key parameter, or if the level and/or
147+
axis parameters are given, a level of the index of the target object.
148+
149+
These are local specifications and will override 'global' settings, that is the parameters
150+
axis and level which are passed to the groupby itself.
145151
146152
Parameters
147153
----------
148-
key : groupby key, default None
149-
level : name, int level number, default None
150-
freq : string / freqency object, default None
151-
sort : boolean, whether to sort the resulting labels, default True
154+
key : string, defaults to None
155+
groupby key, which selects the grouping column of the target
156+
level : name/number, defaults to None
157+
the level for the target index
158+
freq : string / freqency object, defaults to None
159+
This will groupby the specified frequency if the target selection (via key or level) is
160+
a datetime-like object
161+
axis : number/name of the axis, defaults to None
162+
sort : boolean, default to False
163+
whether to sort the resulting labels
152164
153165
Returns
154166
-------
155167
A specification for a groupby instruction
156168
157169
Examples
158170
--------
159-
df.groupby(Group(key='A')) : syntatic sugar for df.groupby('A')
160-
df.groupby(Group(key='date',freq='60s')) : specify a resample on the column 'date'
161-
df.groupby(Group(level='date',freq='60s',axis=1)) :
162-
specify a resample on the level 'date' on the columns axis with a frequency of 60s
171+
>>> df.groupby(Grouper(key='A')) : syntatic sugar for df.groupby('A')
172+
>>> df.groupby(Grouper(key='date',freq='60s')) : specify a resample on the column 'date'
173+
>>> df.groupby(Grouper(level='date',freq='60s',axis=1)) :
174+
specify a resample on the level 'date' on the columns axis with a frequency of 60s
163175
164176
"""
165177

0 commit comments

Comments
 (0)