Skip to content

DOC: fixed references to DataFrameGroupBy methods in comparison_with_… #12491

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

Closed
wants to merge 1 commit into from
Closed
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
11 changes: 7 additions & 4 deletions doc/source/api.rst
Original file line number Diff line number Diff line change
Expand Up @@ -1694,16 +1694,18 @@ application to columns of a specific data type.
.. autosummary::
:toctree: generated/

DataFrameGroupBy.agg
DataFrameGroupBy.all
DataFrameGroupBy.any
DataFrameGroupBy.bfill
DataFrameGroupBy.corr
DataFrameGroupBy.count
DataFrameGroupBy.cov
DataFrameGroupBy.cummax
DataFrameGroupBy.cummin
DataFrameGroupBy.cumprod
DataFrameGroupBy.cumsum
DataFrameGroupBy.describe
DataFrameGroupBy.all
DataFrameGroupBy.any
DataFrameGroupBy.corr
DataFrameGroupBy.cov
DataFrameGroupBy.diff
DataFrameGroupBy.ffill
DataFrameGroupBy.fillna
Expand All @@ -1717,6 +1719,7 @@ application to columns of a specific data type.
DataFrameGroupBy.rank
DataFrameGroupBy.resample
DataFrameGroupBy.shift
DataFrameGroupBy.size
DataFrameGroupBy.skew
DataFrameGroupBy.take
DataFrameGroupBy.tshift
Expand Down
15 changes: 8 additions & 7 deletions doc/source/comparison_with_sql.rst
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,7 @@ Getting items where ``col1`` IS NOT NULL can be done with :meth:`~pandas.Series.

GROUP BY
--------
In pandas, SQL's GROUP BY operations performed using the similarly named
In pandas, SQL's GROUP BY operations are performed using the similarly named
:meth:`~pandas.DataFrame.groupby` method. :meth:`~pandas.DataFrame.groupby` typically refers to a
process where we'd like to split a dataset into groups, apply some function (typically aggregation)
, and then combine the groups together.
Expand All @@ -163,23 +163,24 @@ The pandas equivalent would be:

tips.groupby('sex').size()

Notice that in the pandas code we used :meth:`~pandas.DataFrameGroupBy.size` and not
:meth:`~pandas.DataFrameGroupBy.count`. This is because :meth:`~pandas.DataFrameGroupBy.count`
applies the function to each column, returning the number of ``not null`` records within each.
Notice that in the pandas code we used :meth:`~pandas.core.groupby.DataFrameGroupBy.size` and not
:meth:`~pandas.core.groupby.DataFrameGroupBy.count`. This is because
:meth:`~pandas.core.groupby.DataFrameGroupBy.count` applies the function to each column, returning
the number of ``not null`` records within each.

.. ipython:: python

tips.groupby('sex').count()

Alternatively, we could have applied the :meth:`~pandas.DataFrameGroupBy.count` method to an
individual column:
Alternatively, we could have applied the :meth:`~pandas.core.groupby.DataFrameGroupBy.count` method
to an individual column:

.. ipython:: python

tips.groupby('sex')['total_bill'].count()

Multiple functions can also be applied at once. For instance, say we'd like to see how tip amount
differs by day of the week - :meth:`~pandas.DataFrameGroupBy.agg` allows you to pass a dictionary
differs by day of the week - :meth:`~pandas.core.groupby.DataFrameGroupBy.agg` allows you to pass a dictionary
to your grouped DataFrame, indicating which functions to apply to specific columns.

.. code-block:: sql
Expand Down