听起来您正在寻找的
expanding_window版本
pct_change()。开箱即用不存在此功能,但您可以自己滚动:
df.groupby('security')['price'].apply(lambda x: x.div(x.iloc[0]).subtract(1).mul(100))
听起来您正在寻找的
expanding_window版本
pct_change()。开箱即用不存在此功能,但您可以自己滚动:
df.groupby('security')['price'].apply(lambda x: x.div(x.iloc[0]).subtract(1).mul(100))