From 29eede91bdb0db4add60137d57114b61c0751a99 Mon Sep 17 00:00:00 2001 From: Zach Dwiel Date: Wed, 6 Nov 2013 20:07:11 -0500 Subject: [PATCH] DOC: add basic documentation to some of the GroupBy properties and methods DOC: add GroupBy class to api.rst DOC: add import for GroupBy object to api.rst DOC: add GroupBy.aggregate and GroupBy.transform to api.rst DOC: add meta comment to api.rst about when GroupBy objects are created DOC: add links to api.rst --- doc/source/api.rst | 36 ++++++++++++++++++++++++++++++++++++ pandas/core/groupby.py | 20 ++++++++++++++++++++ 2 files changed, 56 insertions(+) diff --git a/doc/source/api.rst b/doc/source/api.rst index c2c2bc8710af2..4ecde7e05256a 100644 --- a/doc/source/api.rst +++ b/doc/source/api.rst @@ -1112,6 +1112,42 @@ Conversion DatetimeIndex.to_pydatetime +GroupBy +------- +.. currentmodule:: pandas.core.groupby + +GroupBy objects are returned by groupby calls: :func:`pandas.DataFrame.groupby`, :func:`pandas.Series.groupby`, etc. + +Indexing, iteration +~~~~~~~~~~~~~~~~~~~ +.. autosummary:: + :toctree: generated/ + + GroupBy.__iter__ + GroupBy.groups + GroupBy.indices + GroupBy.get_group + +Function application +~~~~~~~~~~~~~~~~~~~~ +.. autosummary:: + :toctree: generated/ + + GroupBy.apply + GroupBy.aggregate + GroupBy.transform + +Computations / Descriptive Stats +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +.. autosummary:: + :toctree: generated/ + + GroupBy.mean + GroupBy.median + GroupBy.std + GroupBy.var + GroupBy.ohlc + .. HACK - see github issue #4539. To ensure old links remain valid, include here the autosummaries with previous currentmodules as a comment and add diff --git a/pandas/core/groupby.py b/pandas/core/groupby.py index 1d5691edb6313..5183ff6484d02 100644 --- a/pandas/core/groupby.py +++ b/pandas/core/groupby.py @@ -226,6 +226,7 @@ def __unicode__(self): @property def groups(self): + """ dict {group name -> group labels} """ return self.grouper.groups @property @@ -234,6 +235,7 @@ def ngroups(self): @property def indices(self): + """ dict {group name -> group indices} """ return self.grouper.indices @property @@ -310,6 +312,22 @@ def curried(x): return wrapper def get_group(self, name, obj=None): + """ + Constructs NDFrame from group with provided name + + Parameters + ---------- + name : object + the name of the group to get as a DataFrame + obj : NDFrame, default None + the NDFrame to take the DataFrame out of. If + it is None, the object groupby was called on will + be used + + Returns + ------- + group : type of obj + """ if obj is None: obj = self.obj @@ -838,6 +856,7 @@ def apply(self, f, data, axis=0): @cache_readonly def indices(self): + """ dict {group name -> group indices} """ if len(self.groupings) == 1: return self.groupings[0].indices else: @@ -884,6 +903,7 @@ def _max_groupsize(self): @cache_readonly def groups(self): + """ dict {group name -> group labels} """ if len(self.groupings) == 1: return self.groupings[0].groups else: