Python Forum
Numpy Rolling mean window
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Numpy Rolling mean window
#1
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
Reply
#2
You should always show the actual and complete, unmodified error traceback as it contains valuable information/
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  [Numpy] How to store different data type in one numpy array? water 7 299 Mar-26-2024, 02:18 PM
Last Post: snippsat
  Rolling window and apply code JunkBoy 6 1,817 Jul-23-2022, 07:00 PM
Last Post: JunkBoy
  Numpy returns "TypeError: unsupported operand type(s) for *: 'numpy.ufunc' and 'int'" kalle 2 2,530 Jul-19-2022, 06:31 AM
Last Post: paul18fr
  Hurst Exponent in Rolling Basis illmattic 1 3,804 Jan-06-2021, 09:49 PM
Last Post: illmattic
  Calculating Beta over Rolling Periods illmattic 2 5,283 Sep-27-2020, 11:27 PM
Last Post: Larz60+
  Apply rolling window function over time dimension of 3D data Staph 0 2,160 Jan-01-2020, 08:31 AM
Last Post: Staph
  Grouping data based on rolling conditions kapilan15 0 1,930 Jun-05-2019, 01:07 PM
Last Post: kapilan15
  "erlarge" a numpy-matrix to numpy-array PhysChem 2 2,932 Apr-09-2019, 04:54 PM
Last Post: PhysChem
  Pandas .rolling() with some calculations inside irmscher 5 6,130 Apr-04-2019, 11:55 AM
Last Post: scidam
  How to use pandas.rolling mean for 3D input array? Prv_Yadv 1 3,811 Mar-26-2019, 11:49 AM
Last Post: scidam

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020