@@ -212,28 +212,30 @@ mean, median, correlation, variance, covariance, standard deviation, skewness,
212
212
and kurtosis. All of these methods are in the :mod: `pandas ` namespace, but
213
213
otherwise they can be found in :mod: `pandas.stats.moments `.
214
214
215
+ .. currentmodule :: pandas
216
+
215
217
.. csv-table ::
216
218
:header: "Function", "Description"
217
219
:widths: 20, 80
218
220
219
- `` rolling_count ` `, Number of non-null observations
220
- `` rolling_sum ` `, Sum of values
221
- `` rolling_mean ` `, Mean of values
222
- `` rolling_median ` `, Arithmetic median of values
223
- `` rolling_min ` `, Minimum
224
- `` rolling_max ` `, Maximum
225
- `` rolling_std ` `, Unbiased standard deviation
226
- `` rolling_var ` `, Unbiased variance
227
- `` rolling_skew ` `, Unbiased skewness (3rd moment)
228
- `` rolling_kurt ` `, Unbiased kurtosis (4th moment)
229
- `` rolling_quantile ` `, Sample quantile (value at %)
230
- `` rolling_apply ` `, Generic apply
231
- `` rolling_cov ` `, Unbiased covariance (binary)
232
- `` rolling_corr ` `, Correlation (binary)
233
- `` rolling_window ` `, Moving window function
221
+ :func: ` rolling_count `, Number of non-null observations
222
+ :func: ` rolling_sum `, Sum of values
223
+ :func: ` rolling_mean `, Mean of values
224
+ :func: ` rolling_median `, Arithmetic median of values
225
+ :func: ` rolling_min `, Minimum
226
+ :func: ` rolling_max `, Maximum
227
+ :func: ` rolling_std `, Unbiased standard deviation
228
+ :func: ` rolling_var `, Unbiased variance
229
+ :func: ` rolling_skew `, Unbiased skewness (3rd moment)
230
+ :func: ` rolling_kurt `, Unbiased kurtosis (4th moment)
231
+ :func: ` rolling_quantile `, Sample quantile (value at %)
232
+ :func: ` rolling_apply `, Generic apply
233
+ :func: ` rolling_cov `, Unbiased covariance (binary)
234
+ :func: ` rolling_corr `, Correlation (binary)
235
+ :func: ` rolling_window `, Moving window function
234
236
235
237
Generally these methods all have the same interface. The binary operators
236
- (e.g. `` rolling_corr ` `) take two Series or DataFrames. Otherwise, they all
238
+ (e.g. :func: ` rolling_corr `) take two Series or DataFrames. Otherwise, they all
237
239
accept the following arguments:
238
240
239
241
- ``window ``: size of moving window
@@ -244,8 +246,8 @@ accept the following arguments:
244
246
Note that prior to pandas v0.8.0, a keyword argument ``time_rule `` was used
245
247
instead of ``freq `` that referred to the legacy time rule constants
246
248
- ``how ``: optionally specify method for down or re-sampling. Default is
247
- is min for `` rolling_min `` , max for `` rolling_max ` `, median for
248
- `` rolling_median ` `, and mean for all other rolling functions. See
249
+ is min for :func: ` rolling_min `, max for :func: ` rolling_max `, median for
250
+ :func: ` rolling_median `, and mean for all other rolling functions. See
249
251
:meth: `DataFrame.resample `'s how argument for more information.
250
252
251
253
These functions can be applied to ndarrays or Series objects:
@@ -265,7 +267,6 @@ sugar for applying the moving window operator to all of the DataFrame's columns:
265
267
266
268
.. ipython :: python
267
269
:suppress:
268
-
269
270
plt.close(' all' )
270
271
271
272
.. ipython :: python
@@ -277,7 +278,7 @@ sugar for applying the moving window operator to all of the DataFrame's columns:
277
278
@savefig rolling_mean_frame.png
278
279
pd.rolling_sum(df, 60 ).plot(subplots = True )
279
280
280
- The `` rolling_apply ` ` function takes an extra ``func `` argument and performs
281
+ The :func: ` rolling_apply ` function takes an extra ``func `` argument and performs
281
282
generic rolling computations. The ``func `` argument should be a single function
282
283
that produces a single value from an ndarray input. Suppose we wanted to
283
284
compute the mean absolute deviation on a rolling basis:
@@ -288,7 +289,7 @@ compute the mean absolute deviation on a rolling basis:
288
289
@savefig rolling_apply_ex.png
289
290
pd.rolling_apply(ts, 60 , mad).plot(style = ' k' )
290
291
291
- The `` rolling_window ` ` function performs a generic rolling window computation
292
+ The :func: ` rolling_window ` function performs a generic rolling window computation
292
293
on the input data. The weights used in the window are specified by the ``win_type ``
293
294
keyword. The list of recognized types are:
294
295
@@ -313,7 +314,7 @@ keyword. The list of recognized types are:
313
314
314
315
pd.rolling_window(ser, 5 , ' triang' )
315
316
316
- Note that the ``boxcar `` window is equivalent to `` rolling_mean ` `.
317
+ Note that the ``boxcar `` window is equivalent to :func: ` rolling_mean `.
317
318
318
319
.. ipython :: python
319
320
@@ -358,7 +359,7 @@ This keyword is available in other rolling functions as well.
358
359
Binary rolling moments
359
360
~~~~~~~~~~~~~~~~~~~~~~
360
361
361
- `` rolling_cov `` and `` rolling_corr ` ` can compute moving window statistics about
362
+ :func: ` rolling_cov ` and :func: ` rolling_corr ` can compute moving window statistics about
362
363
two ``Series `` or any combination of ``DataFrame/Series `` or
363
364
``DataFrame/DataFrame ``. Here is the behavior in each case:
364
365
@@ -447,24 +448,26 @@ they are implemented in pandas such that the following two calls are equivalent:
447
448
Like the ``rolling_ `` functions, the following methods are included in the
448
449
``pandas `` namespace or can be located in ``pandas.stats.moments ``.
449
450
451
+ .. currentmodule :: pandas
452
+
450
453
.. csv-table ::
451
454
:header: "Function", "Description"
452
455
:widths: 20, 80
453
456
454
- `` expanding_count ` `, Number of non-null observations
455
- `` expanding_sum ` `, Sum of values
456
- `` expanding_mean ` `, Mean of values
457
- `` expanding_median ` `, Arithmetic median of values
458
- `` expanding_min ` `, Minimum
459
- `` expanding_max ` `, Maximum
460
- `` expanding_std ` `, Unbiased standard deviation
461
- `` expanding_var ` `, Unbiased variance
462
- `` expanding_skew ` `, Unbiased skewness (3rd moment)
463
- `` expanding_kurt ` `, Unbiased kurtosis (4th moment)
464
- `` expanding_quantile ` `, Sample quantile (value at %)
465
- `` expanding_apply ` `, Generic apply
466
- `` expanding_cov ` `, Unbiased covariance (binary)
467
- `` expanding_corr ` `, Correlation (binary)
457
+ :func: ` expanding_count `, Number of non-null observations
458
+ :func: ` expanding_sum `, Sum of values
459
+ :func: ` expanding_mean `, Mean of values
460
+ :func: ` expanding_median `, Arithmetic median of values
461
+ :func: ` expanding_min `, Minimum
462
+ :func: ` expanding_max `, Maximum
463
+ :func: ` expanding_std `, Unbiased standard deviation
464
+ :func: ` expanding_var `, Unbiased variance
465
+ :func: ` expanding_skew `, Unbiased skewness (3rd moment)
466
+ :func: ` expanding_kurt `, Unbiased kurtosis (4th moment)
467
+ :func: ` expanding_quantile `, Sample quantile (value at %)
468
+ :func: ` expanding_apply `, Generic apply
469
+ :func: ` expanding_cov `, Unbiased covariance (binary)
470
+ :func: ` expanding_corr `, Correlation (binary)
468
471
469
472
Aside from not having a ``window `` parameter, these functions have the same
470
473
interfaces as their ``rolling_ `` counterpart. Like above, the parameters they
@@ -489,7 +492,7 @@ all accept are:
489
492
An expanding window statistic will be more stable (and less responsive) than
490
493
its rolling window counterpart as the increasing window size decreases the
491
494
relative impact of an individual data point. As an example, here is the
492
- `` expanding_mean ` ` output for the previous time series dataset:
495
+ :func: ` expanding_mean ` output for the previous time series dataset:
493
496
494
497
.. ipython :: python
495
498
:suppress:
@@ -512,15 +515,17 @@ A related set of functions are exponentially weighted versions of several of
512
515
the above statistics. A number of expanding EW (exponentially weighted)
513
516
functions are provided:
514
517
518
+ .. currentmodule :: pandas
519
+
515
520
.. csv-table ::
516
521
:header: "Function", "Description"
517
522
:widths: 20, 80
518
523
519
- `` ewma ` `, EW moving average
520
- `` ewmvar ` `, EW moving variance
521
- `` ewmstd ` `, EW moving standard deviation
522
- `` ewmcorr ` `, EW moving correlation
523
- `` ewmcov ` `, EW moving covariance
524
+ :func: ` ewma `, EW moving average
525
+ :func: ` ewmvar `, EW moving variance
526
+ :func: ` ewmstd `, EW moving standard deviation
527
+ :func: ` ewmcorr `, EW moving correlation
528
+ :func: ` ewmcov `, EW moving covariance
524
529
525
530
In general, a weighted moving average is calculated as
526
531
@@ -648,7 +653,7 @@ Whereas if ``ignore_na=True``, the weighted average would be calculated as
648
653
649
654
\frac {(1 -\alpha ) \cdot 3 + 1 \cdot 5 }{(1 -\alpha ) + 1 }.
650
655
651
- The `` ewmvar ``, `` ewmstd `` , and `` ewmcov ` ` functions have a ``bias `` argument,
656
+ The :func: ` ewmvar `, :func: ` ewmstd `, and :func: ` ewmcov ` functions have a ``bias `` argument,
652
657
specifying whether the result should contain biased or unbiased statistics.
653
658
For example, if ``bias=True ``, ``ewmvar(x) `` is calculated as
654
659
``ewmvar(x) = ewma(x**2) - ewma(x)**2 ``;
0 commit comments