Skip to content

Commit 30025d8

Browse files
DOC: update added docs from pandas-dev#14098
1 parent 43928d4 commit 30025d8

File tree

1 file changed

+12
-9
lines changed

1 file changed

+12
-9
lines changed

doc/source/computation.rst

+12-9
Original file line numberDiff line numberDiff line change
@@ -707,22 +707,25 @@ all accept are:
707707

708708
The output of the ``.rolling`` and ``.expanding`` methods do not return a
709709
``NaN`` if there are at least ``min_periods`` non-null values in the current
710-
window. This differs from :meth:`~DataFrame.cumsum`,
710+
window. For example,
711+
712+
.. ipython:: python
713+
714+
sn = pd.Series([1, 2, np.nan, 3, np.nan, 4])
715+
sn
716+
sn.rolling(2).max()
717+
sn.rolling(2, min_periods=1).max()
718+
719+
In case of expanding functions, this differs from :meth:`~DataFrame.cumsum`,
711720
:meth:`~DataFrame.cumprod`, :meth:`~DataFrame.cummax`,
712721
and :meth:`~DataFrame.cummin`, which return ``NaN`` in the output wherever
713-
a ``NaN`` is encountered in the input.
714-
715-
Please see the example below. In order to match the output of ``cumsum``
716-
with ``expanding``, use :meth:`~DataFrame.fillna`.
722+
a ``NaN`` is encountered in the input. In order to match the output of ``cumsum``
723+
with ``expanding``, use :meth:`~DataFrame.fillna`:
717724

718725
.. ipython:: python
719726
720-
sn = pd.Series([1,2,np.nan,3,np.nan,4])
721-
722727
sn.expanding().sum()
723-
724728
sn.cumsum()
725-
726729
sn.cumsum().fillna(method='ffill')
727730
728731

0 commit comments

Comments
 (0)