### DOC: add section on groupby().rolling/expanding/resample (#14801)

This commit is contained in:
parent dc23751b44
commit bcd76ed94d
3 changed files with 56 additions and 0 deletions

#### 5 doc/source/computation.rst View File

 `@ -214,6 +214,11 @@ computing common *window* or *rolling* statistics. Among these are count, sum,` `mean, median, correlation, variance, covariance, standard deviation, skewness,` `and kurtosis.` ``` ``` `Starting in version 0.18.1, the ``rolling()`` and ``expanding()``` `functions can be used directly from DataFrameGroupBy objects,` `see the :ref:`groupby docs `.` ``` ``` ``` ``` `.. note::` ``` ``` ` The API for window statistics is quite similar to the way one works with ``GroupBy`` objects, see the documentation :ref:`here ``

#### 48 doc/source/groupby.rst View File

 `@ -614,6 +614,54 @@ and that the transformed data contains no NAs.` ``` ``` ` grouped.ffill()` ``` ``` ``` ``` `.. _groupby.transform.window_resample:` ``` ``` `New syntax to window and resample operations` `~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~` `.. versionadded:: 0.18.1` ``` ``` `Working with the resample, expanding or rolling operations on the groupby` `level used to require the application of helper functions. However,` `now it is possible to use ``resample()``, ``expanding()`` and` ```rolling()`` as methods on groupbys.` ``` ``` `The example below will apply the ``rolling()`` method on the samples of` `the column B based on the groups of column A.` ``` ``` `.. ipython:: python` ``` ``` ` df = pd.DataFrame({'A': [1] * 10 + [5] * 10,` ` 'B': np.arange(20)})` ` df` ` ` ` df.groupby('A').rolling(4).B.mean()` ``` ``` ``` ``` `The ``expanding()`` method will accumulate a given operation` `(``sum()`` in the example) for all the members of each particular` `group.` ``` ``` `.. ipython:: python` ``` ``` ` df.groupby('A').expanding().sum()` ``` ``` ``` ``` `Suppose you want to use the ``resample()`` method to get a daily` `frequency in each group of your dataframe and wish to complete the` `missing values with the ``ffill()`` method.` ``` ``` `.. ipython:: python` ``` ``` ` df = pd.DataFrame({'date': pd.date_range(start='2016-01-01',` ` periods=4,` ` freq='W'),` ` 'group': [1, 1, 2, 2],` ` 'val': [5, 6, 7, 8]}).set_index('date')` ` df` ``` ``` ` df.groupby('group').resample('1D').ffill()` ``` ``` `.. _groupby.filter:` ``` ``` `Filtration`

#### 3 doc/source/timeseries.rst View File

 `@ -1287,6 +1287,9 @@ limited to, financial applications.` ``` ``` ```.resample()`` is a time-based groupby, followed by a reduction method on each of its groups.` ``` ``` `Starting in version 0.18.1, the ``resample()`` function can be used directly from` `DataFrameGroupBy objects, see the :ref:`groupby docs `.` ``` ``` `.. note::` ``` ``` ` ``.resample()`` is similar to using a ``.rolling()`` operation with a time-based offset, see a discussion `here ``