title: sequential pandas rolling data processing
body: <p>I´m working with pandas rolling-function to generate sequential data. My main window size is 51 and I need to calculate various measures from this initial window with different windows,e.g.:
  dummy data:</p>
  
  <pre><code>df = pd.DataFrame(np.random.randint(0,800,size=(1000, 3)), columns=list('ABC'))
  </code></pre>
  
  <p>My function:</p>
  
  <pre><code>def test(data):
       meanMov = np.zeros((51,3))
       mean = np.mean(data[0:31,:],axis=0)
       for i in range(0,16):
           meanMov[i] = mean
       mean = np.mean(data[20:50,:], axis=0)
       for i in range(35,51):
           meanMov[i] = mean
       for i in range(16,35):
           meanMov[i] = np.mean(data[(i-15):(i+15+1)], axis=0)
       return meanMov.mean()
  </code></pre>
  
  <p>To run the function:</p>
  
  <pre><code>r = df.rolling(51)
   entr = (r.apply(test)).dropna(axis=0, how='all')
  </code></pre>
  
  <p>when I run the function I got the following error:</p>
  
  <pre><code>&gt;&gt;&gt; entr =  (r.apply(test)).dropna(axis=0, how='all')
  Traceback (most recent call last):
    File "&lt;stdin&gt;", line 1, in &lt;module&gt;
    File "C:\Users\AppData\Local\Programs\Python\Python36\lib\site-packages\pandas\core\window.py", line 1207, in apply
      return super(Rolling, self).apply(func, args=args, kwargs=kwargs)
    File "C:\Users\AppData\Local\Programs\Python\Python36\lib\site-packages\pandas\core\window.py", line 856, in apply
      center=False)
    File "C:\Users\AppData\Local\Programs\Python\Python36\lib\site-packages\pandas\core\window.py", line 799, in _apply
      result = np.apply_along_axis(calc, self.axis, values)
    File "C:\Users\AppData\Local\Programs\Python\Python36\lib\site-packages\numpy\lib\shape_base.py", line 116, in apply_along_axis
      res = asanyarray(func1d(inarr_view[ind0], *args, **kwargs))
    File "C:\Users\AppData\Local\Programs\Python\Python36\lib\site-packages\pandas\core\window.py", line 795, in calc
      closed=self.closed)
    File "C:\Users\AppData\Local\Programs\Python\Python36\lib\site-packages\pandas\core\window.py", line 853, in f
      offset, func, args, kwargs)
    File "pandas\_libs\window.pyx", line 1450, in pandas._libs.window.roll_generic (pandas\_libs\window.c:36061)
    File "&lt;stdin&gt;", line 3, in test
  IndexError: too many indices for array
  </code></pre>
  
  <p>How can I calculate the different means for all columns and save them for further processing...</p>
  
  <p>Thanks a lot!</p>