[Solved] Dataframe: Computed row based on cell above and cell on the left
I think you need Series.cumsum with select last row (total row) by DataFrame.iloc: df = pd.DataFrame({ ‘B’:[4,5,4], ‘C’:[7,8,9], ‘D’:[1,3,5], ‘E’:[5,3,6], }) df.loc[‘sum’] = df.sum() df.loc[‘cumsum’] = df.iloc[-1].cumsum() #if need only cumsum row #df.loc[‘cumsum’] = df.sum().cumsum() print (df) B C D E 0 4 7 1 5 1 5 8 3 3 2 4 9 5 … Read more