Skip to content

DOC: add basic documentation to some of the GroupBy properties and methods #5459

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Nov 27, 2013
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
36 changes: 36 additions & 0 deletions doc/source/api.rst
Original file line number Diff line number Diff line change
Expand Up @@ -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__
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think the GroupBy object is available in the pandas namespace. I think you will have to add something like .. currentmodule:: pandas.core.groupby

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
Expand Down
20 changes: 20 additions & 0 deletions pandas/core/groupby.py
Original file line number Diff line number Diff line change
Expand Up @@ -226,6 +226,7 @@ def __unicode__(self):

@property
def groups(self):
""" dict {group name -> group labels} """
return self.grouper.groups

@property
Expand All @@ -234,6 +235,7 @@ def ngroups(self):

@property
def indices(self):
""" dict {group name -> group indices} """
return self.grouper.indices

@property
Expand Down Expand Up @@ -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

Expand Down Expand Up @@ -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:
Expand Down Expand Up @@ -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:
Expand Down