Using the best answer from this post: Reducing noise on Data
I cannot manage to re-use the code to denoise my data-> csv file that can be found here: https://drive.google.com/open?id=1qVOKjDTAIEdB4thiTgv7BmSmfIoDyZ0J
My code:
import pandas as pd
import matplotlib.pyplot as plt
from scipy.signal import lfilter
data = pd.read_csv("Gain_Loss_test.csv")
#plot the original data
x = np.arange(1, 300, 1) # x axis
y = data
plt.plot(x, y, linewidth=1, linestyle="-", c="b")
#apply the filter and plot the denoised data
n = 15 # the larger n is, the smoother curve will be
b = [1.0 / n] * n
a = 1
yy = lfilter(b,a,y)
plt.plot(x, yy, linewidth=1, linestyle="-", c="b")
Both charts look the same, only the scale is changing, in relation to n. I don't want to scale it, i want to smooth it. In the original post, they also use n=15 but the denoised data is not scaled. I tried changing n, only changes scale, no smoothing.
Before filter:
After filter:
Edit: After applying the fix proposed in the answer, all smooth, no scaling !: