pandas.core.window.rolling.Rolling.median¶
- Rolling.median(**kwargs)[source]¶
Calculate the rolling median.
- Parameters
- **kwargs
For compatibility with other rolling methods. Has no effect on the computed median.
- Returns
- Series or DataFrame
Returned type is the same as the original object.
See also
pandas.Series.rollingCalling object with Series data.
pandas.DataFrame.rollingCalling object with DataFrames.
pandas.Series.medianEquivalent method for Series.
pandas.DataFrame.medianEquivalent method for DataFrame.
Examples
Compute the rolling median of a series with a window size of 3.
>>> s = pd.Series([0, 1, 2, 3, 4]) >>> s.rolling(3).median() 0 NaN 1 NaN 2 1.0 3 2.0 4 3.0 dtype: float64