@@ -212,6 +212,7 @@ otherwise they can be found in :mod:`pandas.stats.moments`.
212
212
``rolling_cov ``, Unbiased covariance (binary)
213
213
``rolling_corr ``, Correlation (binary)
214
214
``rolling_corr_pairwise ``, Pairwise correlation of DataFrame columns
215
+ ``rolling_window ``, Moving window function
215
216
216
217
Generally these methods all have the same interface. The binary operators
217
218
(e.g. ``rolling_corr ``) take two Series or DataFrames. Otherwise, they all
@@ -265,6 +266,58 @@ compute the mean absolute deviation on a rolling basis:
265
266
@savefig rolling_apply_ex.png width =4.5in
266
267
rolling_apply(ts, 60 , mad).plot(style = ' k' )
267
268
269
+ The ``rolling_window `` function performs a generic rolling window computation
270
+ on the input data. The weights used in the window are specified by the ``win_type ``
271
+ keyword. The list of recognized types are:
272
+
273
+ - ``boxcar ``
274
+ - ``triang ``
275
+ - ``blackman ``
276
+ - ``hamming ``
277
+ - ``bartlett ``
278
+ - ``parzen ``
279
+ - ``bohman ``
280
+ - ``blackmanharris ``
281
+ - ``nuttall ``
282
+ - ``barthann ``
283
+ - ``kaiser `` (needs beta)
284
+ - ``gaussian `` (needs std)
285
+ - ``general_gaussian `` (needs power, width)
286
+ - ``slepian `` (needs width).
287
+
288
+ .. ipython :: python
289
+
290
+ ser = Series(randn(10 ), index = date_range(' 1/1/2000' , periods = 10 ))
291
+
292
+ rolling_window(ser, 5 , ' triang' )
293
+
294
+ Note that the ``boxcar `` window is equivalent to ``rolling_mean ``:
295
+
296
+ .. ipython :: python
297
+
298
+ rolling_window(ser, 5 , ' boxcar' )
299
+
300
+ rolling_mean(ser, 5 )
301
+
302
+ For some windowing functions, additional parameters must be specified:
303
+
304
+ .. ipython :: python
305
+
306
+ rolling_window(ser, 5 , ' gaussian' , std = 0.1 )
307
+
308
+ By default the labels are set to the right edge of the window, but a
309
+ ``center `` keyword is available so the labels can be set at the center.
310
+ This keyword is available in other rolling functions as well.
311
+
312
+ .. ipython :: python
313
+
314
+ rolling_window(ser, 5 , ' boxcar' )
315
+
316
+ rolling_window(ser, 5 , ' boxcar' , center = True )
317
+
318
+ rolling_mean(ser, 5 , center = True )
319
+
320
+
268
321
.. _stats.moments.binary :
269
322
270
323
Binary rolling moments
@@ -634,4 +687,3 @@ Result fields and tests
634
687
635
688
We'll leave it to the user to explore the docstrings and source, especially as
636
689
we'll be moving this code into statsmodels in the near future.
637
-
0 commit comments