Python Forum
How to use pandas.rolling mean for 3D input array?
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
How to use pandas.rolling mean for 3D input array?
#1
For 1D I can use:

a=np.array([1,2,3,4])
b=pandas.Series(a).rolling(window=3,center=True).mean()
But the problem is, if I have array a, in 3D then using this method gives error

Exception: Data must be 1-dimensional
The code which I used is:

t[:,:,0]=(pd.Series(imgg[:,:,0:4]).rolling(window=[1,1,3],center=True).mean())
Here imgg is 3D numpy array.

What else I tried:

I also tried the old function rolling_mean i.e. pd.rolling_mean(a,4,center=True), but it is also not working, it gives error:

AssertionError: cannot support ndim > 2 for ndarray compat
Reply
#2
It seems that you want to work with images (imgg variable and 3D array). Did you look at scikit-image package. This package includes functions to work with rolling windows in ND space, e.g. this.
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  Rolling window and apply code JunkBoy 6 1,869 Jul-23-2022, 07:00 PM
Last Post: JunkBoy
  how to parse this array with pandas? netanelst 1 1,344 May-17-2022, 12:42 PM
Last Post: netanelst
  Hurst Exponent in Rolling Basis illmattic 1 3,851 Jan-06-2021, 09:49 PM
Last Post: illmattic
  Calculating Beta over Rolling Periods illmattic 2 5,378 Sep-27-2020, 11:27 PM
Last Post: Larz60+
  Read json array data by pandas vipinct 0 1,940 Apr-13-2020, 02:24 PM
Last Post: vipinct
  Apply rolling window function over time dimension of 3D data Staph 0 2,185 Jan-01-2020, 08:31 AM
Last Post: Staph
  Trying to Pass date to pandas search from input prompt curranjohn46 1 2,104 Oct-10-2019, 10:01 AM
Last Post: curranjohn46
  Grouping data based on rolling conditions kapilan15 0 1,951 Jun-05-2019, 01:07 PM
Last Post: kapilan15
  Pandas .rolling() with some calculations inside irmscher 5 6,204 Apr-04-2019, 11:55 AM
Last Post: scidam
  ValueError: could not broadcast input array from shape (75) into shape (25) route2sabya 0 6,481 Mar-14-2019, 01:14 PM
Last Post: route2sabya

Forum Jump:

User Panel Messages

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