Skip to content

Commit de39a15

Browse files
topper-123jorisvandenbossche
authored andcommitted
DOC: minor groupby and resampler improvements (#19514)
1 parent bc1d027 commit de39a15

File tree

3 files changed

+29
-7
lines changed

3 files changed

+29
-7
lines changed

doc/source/groupby.rst

+4-3
Original file line numberDiff line numberDiff line change
@@ -1219,8 +1219,8 @@ see :ref:`here <basics.pipe>`.
12191219
Combining ``.groupby`` and ``.pipe`` is often useful when you need to reuse
12201220
GroupBy objects.
12211221

1222-
For an example, imagine having a DataFrame with columns for stores, products,
1223-
revenue and sold quantity. We'd like to do a groupwise calculation of *prices*
1222+
As an example, imagine having a DataFrame with columns for stores, products,
1223+
revenue and quantity sold. We'd like to do a groupwise calculation of *prices*
12241224
(i.e. revenue/quantity) per store and per product. We could do this in a
12251225
multi-step operation, but expressing it in terms of piping can make the
12261226
code more readable. First we set the data:
@@ -1230,7 +1230,8 @@ code more readable. First we set the data:
12301230
import numpy as np
12311231
n = 1000
12321232
df = pd.DataFrame({'Store': np.random.choice(['Store_1', 'Store_2'], n),
1233-
'Product': np.random.choice(['Product_1', 'Product_2', 'Product_3'], n),
1233+
'Product': np.random.choice(['Product_1',
1234+
'Product_2'], n),
12341235
'Revenue': (np.random.random(n)*50+10).round(2),
12351236
'Quantity': np.random.randint(1, 10, size=n)})
12361237
df.head(2)

pandas/core/generic.py

+24-3
Original file line numberDiff line numberDiff line change
@@ -5691,6 +5691,10 @@ def groupby(self, by=None, axis=0, level=None, as_index=True, sort=True,
56915691
reduce the dimensionality of the return type if possible,
56925692
otherwise return a consistent type
56935693
5694+
Returns
5695+
-------
5696+
GroupBy object
5697+
56945698
Examples
56955699
--------
56965700
DataFrame results
@@ -5702,10 +5706,15 @@ def groupby(self, by=None, axis=0, level=None, as_index=True, sort=True,
57025706
57035707
>>> data.groupby(['col1', 'col2']).mean()
57045708
5705-
Returns
5706-
-------
5707-
GroupBy object
5709+
Notes
5710+
-----
5711+
See the `user guide
5712+
<http://pandas.pydata.org/pandas-docs/stable/groupby.html>`_ for more.
57085713
5714+
See also
5715+
--------
5716+
resample : Convenience method for frequency conversion and resampling
5717+
of time series.
57095718
"""
57105719
from pandas.core.groupby import groupby
57115720

@@ -5904,8 +5913,16 @@ def resample(self, rule, how=None, axis=0, fill_method=None, closed=None,
59045913
59055914
.. versionadded:: 0.19.0
59065915
5916+
Returns
5917+
-------
5918+
Resampler object
5919+
59075920
Notes
59085921
-----
5922+
See the `user guide
5923+
<http://pandas.pydata.org/pandas-docs/stable/timeseries.html#resampling>`_
5924+
for more.
5925+
59095926
To learn more about the offset strings, please see `this link
59105927
<http://pandas.pydata.org/pandas-docs/stable/timeseries.html#offset-aliases>`__.
59115928
@@ -6071,6 +6088,10 @@ def resample(self, rule, how=None, axis=0, fill_method=None, closed=None,
60716088
a b c d
60726089
2000-01-01 00:00:00 0 6 12 18
60736090
2000-01-01 00:03:00 0 4 8 12
6091+
6092+
See also
6093+
--------
6094+
groupby : Group by mapping, function, label, or list of labels.
60746095
"""
60756096
from pandas.core.resample import (resample,
60766097
_maybe_process_deprecations)

pandas/core/groupby.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -230,7 +230,7 @@
230230
Notes
231231
-----
232232
See more `here
233-
<http://pandas.pydata.org/pandas-docs/stable/groupby.html#pipe>`_
233+
<http://pandas.pydata.org/pandas-docs/stable/groupby.html#piping-function-calls>`_
234234
235235
Examples
236236
--------

0 commit comments

Comments
 (0)