Skip to content

Instantly share code, notes, and snippets.

@vvksh
Created November 18, 2017 21:32
Show Gist options
  • Save vvksh/8ba7ee7489bd8ec50c995f6216adcb7d to your computer and use it in GitHub Desktop.
Save vvksh/8ba7ee7489bd8ec50c995f6216adcb7d to your computer and use it in GitHub Desktop.
plot of rolling mean using pandas
#say `x` is list of noisy values
import pandas as pd
import numpy as np
import matplotlib.pyplot as plt
x = np.random.uniform(size=100)
mean_x = pd.Series(x).rolling(window=2).mean()
itr = range(len(mean_x))
plt.xlabel("iterations")
plt.ylabel("X")
plt.title("Rolling Mean")
plt.plot(itr, new_x)
plt.show()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment