此问题在此处已有答案:
How to find the cumulative product in a pandas dataframe column(1个答案)
昨天关门了。
我想知道是否有一种方法可以在新创建的列中与以前派生的值相乘。
import pandas as pd
df = {1: {0: 100.0, 1: 0.96, 2: 0.93, 3: 0.88, 4: 0.85, 5: 0.8}}
1
0 100.00
1 0.96
2 0.93
3 0.88
4 0.85
5 0.80
Logic:
1) 1 = 1
2) 0.96 * 1 (previously derived value) = 0.96
3) 0.93 * (0.96) (previously derived value) = 0.8928
4) 0.88 * (0.8928) (previously derived value) = 0.785664
预期输出:
1条答案
按热度按时间nhn9ugyo1#
您需要
cumprod
除以第一个值:输出量: