title: How to apply rolling mean function by axis 1 python
body: <p>Simply we can calculate  mean by axis:</p>
  
  <pre><code>import pandas as pd
  
  df=pd.DataFrame({'A':[1,1,0,1,0,1,1,0,1,1,1],
                   'b':[1,1,0,1,0,1,1,0,1,1,1],
                   'c':[1,1,0,1,0,1,1,0,1,1,1]}) 
  
  # max_of_three columns 
  mean= np.max(df.mean(axis=1))
  </code></pre>
  
  <p>How to do this same this with rolling mean ?</p>
  
  <p>I tried 1:</p>
  
  <pre><code># max_of_three columns 
  mean=df.rolling(2).mean(axis=1)
  </code></pre>
  
  <p>got this error:</p>
  
  <blockquote>
    <p>UnsupportedFunctionCall: numpy operations are not valid with window objects. Use .rolling(...).mean() instead </p>
  </blockquote>
  
  <p>I tried 2:</p>
  
  <pre><code>def tt(x):
      x=pd.DataFrame(x)
      b1=np.max(x.mean(axis=1))
      return b1
  
  # max_of_three columns 
  mean=df.rolling(2).apply(tt,raw=True)
  </code></pre>
  
  <p>But from here I get three columns in result, in real should be 1 value for each moving window.</p>
  
  <p>Where I am doing mistake? or any other efficient way to doing this.</p>