Skip to content

Commit 6e86c2c

Browse files
committed
Merge pull request #5459 from dwiel/groupby_comments
DOC: add basic documentation to some of the GroupBy properties and methods
2 parents 53e61c6 + 29eede9 commit 6e86c2c

File tree

2 files changed

+56
-0
lines changed

2 files changed

+56
-0
lines changed

doc/source/api.rst

+36
Original file line numberDiff line numberDiff line change
@@ -1112,6 +1112,42 @@ Conversion
11121112
DatetimeIndex.to_pydatetime
11131113

11141114

1115+
GroupBy
1116+
-------
1117+
.. currentmodule:: pandas.core.groupby
1118+
1119+
GroupBy objects are returned by groupby calls: :func:`pandas.DataFrame.groupby`, :func:`pandas.Series.groupby`, etc.
1120+
1121+
Indexing, iteration
1122+
~~~~~~~~~~~~~~~~~~~
1123+
.. autosummary::
1124+
:toctree: generated/
1125+
1126+
GroupBy.__iter__
1127+
GroupBy.groups
1128+
GroupBy.indices
1129+
GroupBy.get_group
1130+
1131+
Function application
1132+
~~~~~~~~~~~~~~~~~~~~
1133+
.. autosummary::
1134+
:toctree: generated/
1135+
1136+
GroupBy.apply
1137+
GroupBy.aggregate
1138+
GroupBy.transform
1139+
1140+
Computations / Descriptive Stats
1141+
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
1142+
.. autosummary::
1143+
:toctree: generated/
1144+
1145+
GroupBy.mean
1146+
GroupBy.median
1147+
GroupBy.std
1148+
GroupBy.var
1149+
GroupBy.ohlc
1150+
11151151
..
11161152
HACK - see github issue #4539. To ensure old links remain valid, include
11171153
here the autosummaries with previous currentmodules as a comment and add

pandas/core/groupby.py

+20
Original file line numberDiff line numberDiff line change
@@ -226,6 +226,7 @@ def __unicode__(self):
226226

227227
@property
228228
def groups(self):
229+
""" dict {group name -> group labels} """
229230
return self.grouper.groups
230231

231232
@property
@@ -234,6 +235,7 @@ def ngroups(self):
234235

235236
@property
236237
def indices(self):
238+
""" dict {group name -> group indices} """
237239
return self.grouper.indices
238240

239241
@property
@@ -310,6 +312,22 @@ def curried(x):
310312
return wrapper
311313

312314
def get_group(self, name, obj=None):
315+
"""
316+
Constructs NDFrame from group with provided name
317+
318+
Parameters
319+
----------
320+
name : object
321+
the name of the group to get as a DataFrame
322+
obj : NDFrame, default None
323+
the NDFrame to take the DataFrame out of. If
324+
it is None, the object groupby was called on will
325+
be used
326+
327+
Returns
328+
-------
329+
group : type of obj
330+
"""
313331
if obj is None:
314332
obj = self.obj
315333

@@ -838,6 +856,7 @@ def apply(self, f, data, axis=0):
838856

839857
@cache_readonly
840858
def indices(self):
859+
""" dict {group name -> group indices} """
841860
if len(self.groupings) == 1:
842861
return self.groupings[0].indices
843862
else:
@@ -884,6 +903,7 @@ def _max_groupsize(self):
884903

885904
@cache_readonly
886905
def groups(self):
906+
""" dict {group name -> group labels} """
887907
if len(self.groupings) == 1:
888908
return self.groupings[0].groups
889909
else:

0 commit comments

Comments
 (0)