0

I have a df with the following structure:

enter image description here

I would like to accumulate in a new column called "Flight1_Accumulated" the sum of the past rows in Flight1. As an example, for index 2020-03-01, this new column will contain the sum of 2020-01-01, 2020-02-01 and 2020-03-01.

I think that probably pandas has an specific function to solve it without iterate rows. Probably dataframe.cumsum() can do it.

The expected results (made with Excel) is: enter image description here

Does anyone know how to solve it?

srgam
  • 366
  • 1
  • 13
  • Can you add expected output? [Also is possible don't post images of code/data (or links to them)](http://meta.stackoverflow.com/questions/285551/why-may-i-not-upload-images-of-code-on-so-when-asking-a-question) ? – jezrael Mar 16 '20 at 10:57
  • Expected results added – srgam Mar 16 '20 at 11:01
  • 1
    So you need `df['Flight1_Accumulated'] = df['Flight1'].cumsum()` ? – jezrael Mar 16 '20 at 11:02

0 Answers0