import pandas as pd t_med_average = np.empty((25,101,301)) t_95_average = np.empty((25,101,301)) for i in range(24,49): for j in range (0,101): for k in range(0,301): d = pd.Series(t_median[i,j,k]) t_med_average[i,j,k] = d.rolling(24).mean() for i in range(24,49): for j in range (0,101): for k in range(0,301): d = pd.Series(t_95[i,j,k]) t_95_average[i,j,k] = d.rolling(24).mean()