Python 添加下一个12个月累计回报的列
我面临以下问题。我想添加一个额外的列,用于计算未来12个月的累计绩效(月度绩效=调整后的收盘价) 数据如下:Python 添加下一个12个月累计回报的列,python,pandas,dataframe,Python,Pandas,Dataframe,我面临以下问题。我想添加一个额外的列,用于计算未来12个月的累计绩效(月度绩效=调整后的收盘价) 数据如下: print(Overview2) Adjusted Close PMI % Change PMI Date 2020-12-31 0.000000 60.5 0.000000 2020-11-30 -0.035793 57.7
print(Overview2)
Adjusted Close PMI % Change PMI
Date
2020-12-31 0.000000 60.5 0.000000
2020-11-30 -0.035793 57.7 -0.046281
2020-10-30 -0.097103 58.8 0.019064
2020-09-30 0.028453 55.7 -0.052721
2020-08-31 0.040830 55.6 -0.001795
... ... ... ...
1970-05-29 0.052668 47.2 -0.076321
1970-04-30 0.064925 45.0 -0.046610
1970-03-31 0.099485 46.9 0.042222
1970-02-27 -0.001450 47.4 0.010661
1970-01-30 -0.050056 48.7 0.027426
[612 rows x 3 columns]
我想为整个表格添加“12个月绩效”一栏,计算绩效如下:
Adjusted Close PMI % Change PMI Performance 12 Month
1970-01-30 -0.050056 48.7 0.027426 Performance from 31.12.1969 -
31.12.1970
1970-02-27 -0.001450 47.4 0.010661 Performance from 31.01.1970 -
31.1.1971