…lines 1–2037 unchanged (2037 lines)
2038 raise ValueError(f"{on} {msg}")
2039
2040 def aggregate(self, func=None, *args, **kwargs):
2041 """
2042 Aggregate using one or more operations over the specified axis.
2043
2044 This method allows combining multiple aggregation functions (e.g.
2045 ``'sum'``, ``'mean'``) in a single call, returning a result for each
2046 function applied to each rolling window.
2047
2048 Parameters
2049 ----------
2050 func : function, str, list or dict
2051 Function to use for aggregating the data. If a function, must either
2052 work when passed a Series/Dataframe or
2053 when passed to Series/Dataframe.apply.
2054
…lines 2055–2123 unchanged (69 lines)
2124 agg = aggregate
2125
2126 def count(self, numeric_only: bool = False):
2127 """
2128 Calculate the rolling count of non NaN observations.
2129
2130 This is useful for identifying windows with missing data, as it counts
2131 only non-NaN entries within each window.
2132
2133 Parameters
2134 ----------
2135 numeric_only : bool, default False
2136 Include only float, int, boolean columns.
2137
2138 Returns
2139 -------
…lines 2140–2179 unchanged (40 lines)
2180 args: tuple[Any, ...] | None = None,
2181 kwargs: dict[str, Any] | None = None,
2182 ):
2183 """
2184 Calculate the rolling custom aggregation function.
2185
2186 Applies an arbitrary function to each rolling window. This is useful
2187 when the built-in rolling methods do not cover the desired computation.
2188
2189 Parameters
2190 ----------
2191 func : function
2192 Must produce a single value from an ndarray input if ``raw=True``
2193 or a single value from a Series if ``raw=False``. Can also accept a
2194 Numba JIT function with ``engine='numba'`` specified.
2195
…lines 2196–2364 unchanged (169 lines)
2365 engine: Literal["cython", "numba"] | None = None,
2366 engine_kwargs: dict[str, bool] | None = None,
2367 ):
2368 """
2369 Calculate the rolling sum.
2370
2371 This is equivalent to applying ``numpy.sum`` over each rolling window.
2372 Missing values (NaN) are excluded from the calculation.
2373
2374 Parameters
2375 ----------
2376 numeric_only : bool, default False
2377 Include only float, int, boolean columns.
2378
2379 engine : str, default None
2380 * ``'cython'`` : Runs the operation through C-extensions from cython.
…lines 2381–2466 unchanged (86 lines)
2467 engine_kwargs: dict[str, bool] | None = None,
2468 **kwargs,
2469 ):
2470 """
2471 Calculate the rolling maximum.
2472
2473 This is equivalent to applying ``numpy.max`` over each rolling window.
2474
2475 Parameters
2476 ----------
2477 numeric_only : bool, default False
2478 Include only float, int, boolean columns.
2479
2480 *args : iterable, optional
2481 Positional arguments passed into ``func``.
…lines 2482–2537 unchanged (56 lines)
2538 engine: Literal["cython", "numba"] | None = None,
2539 engine_kwargs: dict[str, bool] | None = None,
2540 ):
2541 """
2542 Calculate the rolling minimum.
2543
2544 This is equivalent to applying ``numpy.min`` over each rolling window.
2545
2546 Parameters
2547 ----------
2548 numeric_only : bool, default False
2549 Include only float, int, boolean columns.
2550
2551 engine : str, default None
2552 * ``'cython'`` : Runs the operation through C-extensions from cython.
…lines 2553–2605 unchanged (53 lines)
2606 engine: Literal["cython", "numba"] | None = None,
2607 engine_kwargs: dict[str, bool] | None = None,
2608 ):
2609 """
2610 Calculate the rolling mean.
2611
2612 This is equivalent to applying ``numpy.mean`` over each rolling window.
2613
2614 Parameters
2615 ----------
2616 numeric_only : bool, default False
2617 Include only float, int, boolean columns.
2618
2619 engine : str, default None
2620 * ``'cython'`` : Runs the operation through C-extensions from cython.
…lines 2621–2680 unchanged (60 lines)
2681 engine: Literal["cython", "numba"] | None = None,
2682 engine_kwargs: dict[str, bool] | None = None,
2683 ):
2684 """
2685 Calculate the rolling median.
2686
2687 This is equivalent to applying ``numpy.median`` over each rolling
2688 window.
2689
2690 Parameters
2691 ----------
2692 numeric_only : bool, default False
2693 Include only float, int, boolean columns.
2694
2695 engine : str, default None
2696 * ``'cython'`` : Runs the operation through C-extensions from cython.
…lines 2697–2750 unchanged (54 lines)
2751 engine: Literal["cython", "numba"] | None = None,
2752 engine_kwargs: dict[str, bool] | None = None,
2753 ):
2754 """
2755 Calculate the rolling standard deviation.
2756
2757 This is equivalent to applying ``numpy.std`` (with the specified
2758 ``ddof``) over each rolling window.
2759
2760 Parameters
2761 ----------
2762 ddof : int, default 1
2763 Delta Degrees of Freedom. The divisor used in calculations
2764 is ``N - ddof``, where ``N`` represents the number of elements.
2765
2766 numeric_only : bool, default False
…lines 2767–2827 unchanged (61 lines)
2828 engine: Literal["cython", "numba"] | None = None,
2829 engine_kwargs: dict[str, bool] | None = None,
2830 ):
2831 """
2832 Calculate the rolling variance.
2833
2834 This is equivalent to applying ``numpy.var`` (with the specified
2835 ``ddof``) over each rolling window.
2836
2837 Parameters
2838 ----------
2839 ddof : int, default 1
2840 Delta Degrees of Freedom. The divisor used in calculations
2841 is ``N - ddof``, where ``N`` represents the number of elements.
2842
2843 numeric_only : bool, default False
…lines 2844–2898 unchanged (55 lines)
2899 )
2900
2901 def skew(self, numeric_only: bool = False):
2902 """
2903 Calculate the rolling unbiased skewness.
2904
2905 This is equivalent to applying ``scipy.stats.skew`` over each rolling
2906 window. A minimum of three periods is required.
2907
2908 Parameters
2909 ----------
2910 numeric_only : bool, default False
2911 Include only float, int, boolean columns.
2912
2913 Returns
2914 -------
…lines 2915–2942 unchanged (28 lines)
2943 return super().skew(numeric_only=numeric_only)
2944
2945 def sem(self, ddof: int = 1, numeric_only: bool = False):
2946 """
2947 Calculate the rolling standard error of mean.
2948
2949 This is computed as the rolling standard deviation divided by the
2950 square root of the rolling count. A minimum of one period is required.
2951
2952 Parameters
2953 ----------
2954 ddof : int, default 1
2955 Delta Degrees of Freedom. The divisor used in calculations
2956 is ``N - ddof``, where ``N`` represents the number of elements.
2957
2958 numeric_only : bool, default False
…lines 2959–2990 unchanged (32 lines)
2991 ).pow(0.5)
2992
2993 def kurt(self, numeric_only: bool = False):
2994 """
2995 Calculate the rolling Fisher's definition of kurtosis without bias.
2996
2997 This is equivalent to applying ``scipy.stats.kurtosis`` (with
2998 ``bias=False``) over each rolling window. A minimum of four periods
2999 is required.
3000
3001 Parameters
3002 ----------
3003 numeric_only : bool, default False
3004 Include only float, int, boolean columns.
3005
3006 Returns
3007 -------
…lines 3008–3042 unchanged (35 lines)
3043 return super().kurt(numeric_only=numeric_only)
3044
3045 def first(self, numeric_only: bool = False):
3046 """
3047 Calculate the rolling First (left-most) element of the window.
3048
3049 Return the first observed value in each rolling window. This is useful
3050 for tracking the starting value of a window as it slides forward.
3051
3052 Parameters
3053 ----------
3054 numeric_only : bool, default False
3055 Include only float, int, boolean columns.
3056
3057 Returns
3058 -------
…lines 3059–3080 unchanged (22 lines)
3081 return super().first(numeric_only=numeric_only)
3082
3083 def last(self, numeric_only: bool = False):
3084 """
3085 Calculate the rolling Last (right-most) element of the window.
3086
3087 Return the last observed value in each rolling window. This is useful
3088 for tracking the most recent value of a window as it slides forward.
3089
3090 Parameters
3091 ----------
3092 numeric_only : bool, default False
3093 Include only float, int, boolean columns.
3094
3095 Returns
3096 -------
…lines 3097–3123 unchanged (27 lines)
3124 interpolation: QuantileInterpolation = "linear",
3125 numeric_only: bool = False,
3126 ):
3127 """
3128 Calculate the rolling quantile.
3129
3130 Return the ``q``-th quantile of the values in each rolling window. The
3131 ``interpolation`` parameter controls how quantiles falling between two
3132 data points are handled.
3133
3134 Parameters
3135 ----------
3136 q : float
3137 Quantile to compute. 0 <= quantile <= 1.
3138
3139 interpolation : {'linear', 'lower', 'higher', 'midpoint', 'nearest'}
3140 This optional parameter specifies the interpolation method to use,
…lines 3141–3191 unchanged (51 lines)
3192 pct: bool = False,
3193 numeric_only: bool = False,
3194 ):
3195 """
3196 Calculate the rolling rank.
3197
3198 Compute the rank of each value within each rolling window. Ties are
3199 resolved using the ``method`` parameter.
3200
3201 Parameters
3202 ----------
3203 method : {'average', 'min', 'max'}, default 'average'
3204 How to rank the group of records that have the same value (i.e. ties):
3205
3206 * average: average rank of the group
3207 * min: lowest rank in the group
…lines 3208–3316 unchanged (109 lines)
3317 ddof: int = 1,
3318 numeric_only: bool = False,
3319 ):
3320 """
3321 Calculate the rolling sample covariance.
3322
3323 Compute the sample covariance between the calling object and ``other``
3324 over each rolling window. If ``other`` is not supplied, pairwise
3325 covariances of the columns are computed.
3326
3327 Parameters
3328 ----------
3329 other : Series or DataFrame, optional
3330 If not supplied then will default to self and produce pairwise
3331 output.
3332
3333 pairwise : bool, default None
…lines 3334–3381 unchanged (48 lines)
3382 ddof: int = 1,
3383 numeric_only: bool = False,
3384 ):
3385 """
3386 Calculate the rolling correlation.
3387
3388 Compute the Pearson correlation coefficient between the calling object
3389 and ``other`` over each rolling window. If ``other`` is not supplied,
3390 pairwise correlations of the columns are computed.
3391
3392 Parameters
3393 ----------
3394 other : Series or DataFrame, optional
3395 If not supplied then will default to self and produce pairwise
3396 output.
3397
3398 pairwise : bool, default None
…lines 3399–3576 unchanged (178 lines)