Skip to content

Commit ce38e6f

Browse files
author
Chang She
committed
DOC: rolling apply example #1210
1 parent ce86c30 commit ce38e6f

File tree

1 file changed

+11
-0
lines changed

1 file changed

+11
-0
lines changed

doc/source/computation.rst

+11
Original file line numberDiff line numberDiff line change
@@ -205,6 +205,17 @@ sugar for applying the moving window operator to all of the DataFrame's columns:
205205
@savefig rolling_mean_frame.png width=4.5in
206206
rolling_sum(df, 60).plot(subplots=True)
207207
208+
The ``rolling_apply`` function takes an extra ``func`` argument and performs
209+
generic rolling computations. The ``func`` argument should be a single function
210+
that produces a single value from an ndarray input. Suppose we wanted to
211+
compute the mean absolute deviation on a rolling basis:
212+
213+
.. ipython:: python
214+
215+
mad = lambda x: np.fabs(x - x.mean()).mean()
216+
@savefig rolling_apply_ex.png width=4.5in
217+
rolling_apply(ts, 60, mad).plot(style='k')
218+
208219
.. _stats.moments.binary:
209220

210221
Binary rolling moments

0 commit comments

Comments
 (0)