data[np.random.randint(0, n - 1, n_miss)] = None
windowed_mean = pd.Series(data).rolling(window=win_size, min_periods=1).mean()
print(pd.DataFrame({'Data': data, 'Windowed mean': windowed_mean}))
Python: Sliding windowed mean, ignoring missing data