title: Sum last X column values into new column
body: <p>A pandas/numpy noob, I have a little problem I am going around in circles solving...</p>
  
  <p>A simple data structure from a csv, I have been able to sort it by <code>PADD_NAME</code> and image_date: </p>
  
  <pre><code>PADD_NAME __fid__ count image_date majority max mean median min minority range std sum unique
  1662 Big Pan 3 3037 19800201 14.4 14.400000 14.400000 13.600000 13.600000 13.6 0 0.000001 41303.199219 1
  2229 Big Pan 3 3037 19800301 11.9 11.900000 11.900002 14.400000 14.400000 14.4 0 0.000001 43732.800781 1
  4539 Big Pan 3 3037 19800401 7.2 7.200000 7.200000 11.900000 11.900000 11.9 0 0.000002 36140.304688 1
  2607 Big Pan 3 3037 19800501 18.3 18.299999 18.300001 7.200000 7.200000 7.2 0 0.000000 21866.400391 1
  5799 Big Pan 3 3037 19800101 13.6 13.600000 13.600000 18.299999 18.299999 18.3 0 0.000002 55577.101562 1"
  </code></pre>
  
  <p>I would simply like to add a column and populate with it with the <code>cum. sum</code> of the last three values of the <code>mean</code> column:</p>
  
  <pre><code>PADD_NAME __fid__ count image_date majority max mean median min minority range std sum unique sum_mean_last3 
  1662 Big Pan 3 3037 19800201 14.4 14.400000 14.400000 13.600000 13.600000 13.6 0 0.000001 41303.199219 1
  2229 Big Pan 3 3037 19800301 11.9 11.900000 11.900002 14.400000 14.400000 14.4 0 0.000001 43732.800781 1 
  4539 Big Pan 3 3037 19800401 7.2 7.200000 7.200000 11.900000 11.900000 11.9 0 0.000002 36140.304688 1 33.5
  2607 Big Pan 3 3037 19800501 18.3 18.299999 18.300001 7.200000 7.200000 7.2 0 0.000000 21866.400391 1 37.4
  5799 Big Pan 3 3037 19800101 13.6 13.600000 13.600000 18.299999 18.299999 18.3 0 0.000002 55577.101562 1 39.1
  </code></pre>
  
  <p>The <code>mean</code> values are a measure of monthly ground-cover (at time <code>image_date</code>), and I am looking to generate "seasonal" values (summer,autumn,...) - I realise the seasonal sums should start at the correct month, however getting this first step in would be a great help..</p>
  
  <hr>
  
  <p>I have found and tried a few 'recipes' for sort-of-similar problems, but have got nowhere except confused:</p>
  
  <ul>
  <li><a href="https://stackoverflow.com/questions/29782898/combine-pandas-data-frame-column-values-into-new-column">Combine Pandas data frame column values into new column</a></li>
  <li><a href="https://stackoverflow.com/questions/20181456/sum-up-column-values-in-pandas-dataframe">Sum up column values in Pandas DataFrame</a></li>
  <li><a href="https://stackoverflow.com/questions/17698975/pandas-convert-dataframe-column-values-into-new-dataframe-indices-and-columns">Pandas: Convert DataFrame Column Values Into New Dataframe Indices and Columns</a></li>
  </ul>
  
  <p>Thanks in advance for any advice!</p>