Python pandas-当先前索引为分母和分子时的cumprod

Python pandas-当先前索引为分母和分子时的cumprod,python,pandas,Python,Pandas,我有一个熊猫系列(DivFactor)我想用cumprod计算。它取决于另外两个给定序列:AdjClose和Div 以下是我当前的循环: DivFactor[0] = 1 for t in range(1, periods): DivFactor[t] = DivFactor[t-1] - (Div[t-1] * DivFactor[t-1]) / (AdjClose[t] / DivFactor[t-1] + D

我有一个熊猫
系列
DivFactor
)我想用cumprod计算。它取决于另外两个给定序列:
AdjClose
Div

以下是我当前的循环:

DivFactor[0] = 1
for t in range(1, periods):
    DivFactor[t] = DivFactor[t-1] - (Div[t-1] * DivFactor[t-1]) /
                                     (AdjClose[t] / DivFactor[t-1] + Div[t-1]))
问题是,这个公式似乎很难用累积积来表示


有没有办法重铸DivFactor,这样我就可以使用cumprod(或另一个累积函数)并避免使用Python循环?

仅仅通过查看它,我不知道一个好方法。我怀疑一个简短的Cython函数()可能是加速这个过程的最好方法