0

给定一个带有周期性 IRR 回报的 pandas 数据框,df:

Name | Begin      | End        | IRR 
A    | 2010-06-30 | 2010-07-31 | 0.037480 
B    | 2010-07-31 | 2010-08-31 |-0.009710 
C    | 2010-08-31 | 2010-09-30 | 0.023160  

其中每个 IRR 值对应于每个月的回报。

我想根据不同的月度获得累计 IRR 回报。这里的想法是“累加”或累积之前所有月份的每个月的回报,这样 IRR 的最后一个值就具有所有之前回报值的历史记录。

到目前为止,我有

df['Cumulative IRR'] = df.sort_values(by=['Name', 'Begin']).groupby(by=['Name', 'Begin', 'End', 'IRR']).prod().groupby(level=0).cumprod()-1

但是我得到了错误:

DataError: No numeric types to aggregate

任何提示将不胜感激。

4

0 回答 0