Python Forum
Numpy Rolling mean window - Printable Version

+- Python Forum (https://python-forum.io)
+-- Forum: Python Coding (https://python-forum.io/forum-7.html)
+--- Forum: Data Science (https://python-forum.io/forum-44.html)
+--- Thread: Numpy Rolling mean window (/thread-10937.html)



Numpy Rolling mean window - Thunberd - Jun-13-2018

Graph = pd.read_csv(file)

    Pl = Graph.dropna()
    
    
    fig = plt.figure()
    ax1 = fig.add_subplot(1, 1, 1)
    df2 = Pl.filter(regex= 'Mean')
    col = df2.loc[: , "Mean1":"Mean14"]
    col2 = df2.loc[: , "Mean1":"Mean14"]
    Pl['Average'] = col.mean(axis=1)
    Pl['Moving'] = col2.rolling(2).mean(axis=1)

    df2.plot(ax = ax1)
    df3 = Pl.filter(like= 'Aver')
    df4 = Pl.filter(like= 'Moving')
I then go on to plot df3 and df4 on a twinx()

When I do this It gives me the error
"UnsupportedFunctionCall: numpy operations are not valid with window objects. Use .rolling(...).mean() instead " So obviously the rolling mean isnt going to work with df4 but How can I fix this? Wall Thanks a bunch in Advance! Pray


RE: Numpy Rolling mean window - Larz60+ - Jun-14-2018

You should always show the actual and complete, unmodified error traceback as it contains valuable information/