# pandas.core.window.Rolling.mean¶

Calculate the rolling mean of the values.

*args Under Review. **kwargs Under Review. :return: Series or DataFrame

Returned object type is determined by the caller of the rolling calculation.

## Limitations¶

DataFrame/Series elements cannot be max/min float/integer. Otherwise SDC and Pandas results are different.

## Examples¶

Calculate the rolling mean of the values.
import pandas as pd
from numba import njit

@njit
def series_rolling_mean():
series = pd.Series([4, 3, 5, 2, 6])  # Series of 4, 3, 5, 2, 6
out_series = series.rolling(3).mean()

return out_series  # Expect series of NaN, NaN, 4.000000, 3.333333, 4.333333

print(series_rolling_mean())

$python ./series/rolling/series_rolling_mean.py 0 NaN 1 NaN 2 4.000000 3 3.333333 4 4.333333 dtype: float64  Calculate the rolling mean of the values. import pandas as pd from numba import njit @njit def df_rolling_mean(): df = pd.DataFrame({'A': [4, 3, 5, 2, 6], 'B': [-4, -3, -5, -2, -6]}) out_df = df.rolling(3).mean() # Expect DataFrame of # {'A': [NaN, NaN, 4.000000, 3.333333, 4.333333], # 'B': [NaN, NaN, -4.000000, -3.333333, -4.333333]} return out_df print(df_rolling_mean())  $ python ./dataframe/rolling/dataframe_rolling_mean.py
A         B
0       NaN       NaN
1       NaN       NaN
2  4.000000 -4.000000
3  3.333333 -3.333333
4  4.333333 -4.333333


Series.rolling

Calling object with a Series.

DataFrame.rolling

Calling object with a DataFrame.

Series.mean

Similar method for Series.

DataFrame.mean

Similar method for DataFrame.