How to multiply iteratively down a column?

前端 未结 2 1613
长情又很酷
长情又很酷 2021-01-21 11:45

I am having a tough time with this one - not sure why...maybe it\'s the late hour.

I have a dataframe in pandas as follows:

1     10
2     11
3     20
4          


        
2条回答
  •  逝去的感伤
    2021-01-21 11:53

    Use cumprod.

    Example:

    df = pd.DataFrame({'A': [10, 11, 20, 5, 10]}, index=range(1, 6))
    df['cprod'] = df['A'].cumprod()
    

提交回复
热议问题