title: Variable shift in a pandas dataframe
body: <pre><code>import pandas as pd
  
  df = pd.DataFrame({'A':[3,5,3,4,2,3,2,3,4,3,2,2,2,3],
                     'B':[10,20,30,40,20,30,40,10,20,30,15,60,20,15]})
  
      A   B
  0   3  10
  1   5  20
  2   3  30
  3   4  40
  4   2  20
  5   3  30
  6   2  40
  7   3  10
  8   4  20
  9   3  30
  10  2  15
  11  2  60
  12  2  20
  13  3  15
  </code></pre>
  
  <p>I'd like to append a <code>C</code> column, containing rolling average of <code>B</code> (rolling period = <code>A</code>).</p>
  
  <p>For example, the <code>C</code> value at <code>row index(2)</code> should be <code>df.B.rolling(3).mean() = mean(10,20,30)</code>, and the <code>C</code> value at <code>row index(4)</code> should be <code>df.B.rolling(2).mean() = mean(40,20)</code>.</p>