Cumprod在Python中提供-inf

时间:2018-08-31 13:22:10

标签: python pandas statistics

我正在尝试计算以下数据集的累积乘积。

 Date   Random data
    1/2/2006    2.372388507
    1/3/2006    2.792095479
    1/4/2006    4.153345633
    1/5/2006    1.209302413
    1/6/2006    3.308908843
    1/9/2006    5.609288688
    1/10/2006   5.148763856
    1/11/2006   4.963421605
    1/12/2006   4.031740124
    1/13/2006   5.475643588
    1/16/2006   5.310478512
    1/17/2006   5.231183268
    1/18/2006   7.33295124
    1/19/2006   7.086467341
    1/20/2006   6.953441702
    1/23/2006   6.881551417
    1/24/2006   6.720592121
    1/25/2006   4.375483647
    1/26/2006   2.824165469
    1/27/2006   2.830542833
    1/30/2006   3.735049499
    1/31/2006   3.147491688
    2/1/2006    1.414748374
    2/2/2006    -0.051161849
    2/3/2006    -0.180186506
    2/6/2006    1.660894524
    2/7/2006    2.709409323
    2/8/2006    1.972035231
    2/9/2006    -0.782625682
    2/10/2006   -1.901299484
    2/13/2006   -2.141229007
    2/14/2006   -2.639233019
    2/15/2006   -4.95219641
    2/16/2006   -6.568204721
    2/17/2006   -5.671892621
    2/20/2006   -5.989308797
    2/21/2006   -5.519832515
    2/22/2006   -4.123507939
    2/23/2006   -4.840716254
    2/24/2006   -3.393895281
    2/27/2006   -1.579450628
    2/28/2006   -5.715894843
    3/1/2006    -4.818584424
    3/2/2006    -5.306398625
    3/3/2006    -3.773552658
    3/6/2006    -1.782726837
    3/7/2006    -2.421770003
    3/8/2006    -2.032466154
    3/9/2006    -3.24379646
    3/10/2006   0.267982805
    3/13/2006   0.014589559
    3/14/2006   1.343058431
    3/15/2006   1.539251495
    3/16/2006   -0.350651804
    3/17/2006   -0.215041321
    3/20/2006   0.578951429
    3/21/2006   -0.576824159
    3/22/2006   1.881264415
    3/23/2006   2.714386498
    3/24/2006   4.111298817
    3/27/2006   5.020309083
    3/28/2006   4.532650354
    3/29/2006   7.245341261
    3/30/2006   8.111802803
    3/31/2006   4.558323469
    4/3/2006    6.252751308
    4/4/2006    8.314806951
    4/5/2006    5.777692349
    4/6/2006    6.725161553
    4/7/2006    4.794367906
    4/10/2006   5.743532122
    4/11/2006   7.290548166
    4/12/2006   5.903857018
    4/13/2006   4.77936565
    4/14/2006   5.674446806
    4/17/2006   5.88485792
    4/18/2006   6.078651917
    4/19/2006   4.917405394
    4/20/2006   4.868584712
    4/21/2006   3.526253732
    4/24/2006   5.124797759
    4/25/2006   3.884862865
    4/26/2006   4.369885748
    4/27/2006   1.234703037
    4/28/2006   -1.67674986
    5/1/2006    -2.711339347
    5/2/2006    -2.574835748
    5/3/2006    -3.532974512
    5/4/2006    -4.361912086
    5/5/2006    -9.136912315
    5/8/2006    -8.945826752
    5/9/2006    -7.804639384
    5/10/2006   -10.05905437
    5/11/2006   -9.254733416
    5/12/2006   -8.382467816
    5/15/2006   -7.718500019
    5/16/2006   -10.04179082
    5/17/2006   -10.90960283
    5/18/2006   -7.538484374
    5/19/2006   -6.915045472
    5/22/2006   -8.49018374
    5/23/2006   -10.84341146
    5/24/2006   -4.739280009
    5/25/2006   -8.906757979
    5/26/2006   -10.61262457
    5/29/2006   -9.636827323
    5/30/2006   -8.353511534
    5/31/2006   -10.1389515
    6/1/2006    -10.0339179
    6/2/2006    -10.84551313
    6/5/2006    -8.628081538
    6/6/2006    -6.657905529
    6/7/2006    -6.395791873
    6/8/2006    -7.676135515
    6/9/2006    -7.225332776
    6/12/2006   -5.721847599
    6/13/2006   -9.168934478
    6/14/2006   -8.522434172
    6/15/2006   -9.344608517
    6/16/2006   -9.492790802
    6/19/2006   -6.27304367
    6/20/2006   -7.748707965
    6/21/2006   -5.216536389
    6/22/2006   -5.866333313
    6/23/2006   -3.421767661
    6/26/2006   -0.817150639
    6/27/2006   1.566919066
    6/28/2006   2.1756715
    6/29/2006   2.003892417
    6/30/2006   0.145706902
    7/3/2006    4.825841191
    7/4/2006    2.984194983
    7/5/2006    2.733606852
    7/6/2006    3.990344988
    7/7/2006    4.464159978
    7/10/2006   2.181922905
    7/11/2006   4.207532649
    7/12/2006   5.893857763
    7/13/2006   6.696591003
    7/14/2006   8.02397588
    7/17/2006   7.18005379
    7/18/2006   7.110823813
    7/19/2006   4.604122492
    7/20/2006   4.383075987
    7/21/2006   4.734463235
    7/24/2006   5.60625391
    7/25/2006   7.453657745
    7/26/2006   6.7147771
    7/27/2006   5.255477178
    7/28/2006   6.638942489
    7/31/2006   5.514850947
    8/1/2006    6.666282084
    8/2/2006    6.037577365
    8/3/2006    6.434382521
    8/4/2006    5.80948075
    8/7/2006    5.667054317
    8/8/2006    5.175715003
    8/9/2006    4.94937506
    8/10/2006   3.558925269
    8/11/2006   4.031802401
    8/14/2006   3.272287286
    8/15/2006   4.289470879
    8/16/2006   3.538103725
    8/17/2006   2.762386707
    8/18/2006   2.114880041
    8/21/2006   5.068950919
    8/22/2006   2.483874694
    8/23/2006   1.730699516
    8/24/2006   -0.675212673
    8/25/2006   0.187110629
    8/28/2006   0.344282156
    8/29/2006   0.01723009
    8/30/2006   -0.327127005
    8/31/2006   0.016483468
    9/1/2006    -0.973496098
    9/4/2006    -1.218588549
    9/5/2006    -0.20940671
    9/6/2006    0.25023559
    9/7/2006    -2.986442703
    9/8/2006    -2.073033591
    9/11/2006   1.390003709
    9/12/2006   2.940760338
    9/13/2006   2.403386183
    9/14/2006   2.349487863
    9/15/2006   1.899995646
    9/18/2006   3.50536463
    9/19/2006   2.83392064
    9/20/2006   2.571588424
    9/21/2006   3.118297653
    9/22/2006   -0.377687298
    9/25/2006   -2.391993686
    9/26/2006   0.712594429
    9/27/2006   1.457682028
    9/28/2006   1.474114727
    9/29/2006   0.446453108
    10/2/2006   3.007973689
    10/3/2006   -2.43263121
    10/4/2006   0.86295345
    10/5/2006   4.664733649
    10/6/2006   4.558573046
    10/9/2006   4.680665577
    10/10/2006  4.575158956
    10/11/2006  6.425144162
    10/12/2006  8.372432637
    10/13/2006  8.182474544
    10/16/2006  8.968786366
    10/17/2006  9.463661551
    10/18/2006  8.512907068
    10/19/2006  5.873743873
    10/20/2006  3.369445264
    10/23/2006  1.030307363
    10/24/2006  5.528218034
    10/25/2006  4.772900213
    10/26/2006  4.780839053
    10/27/2006  4.908377081
    10/30/2006  1.949064709
    10/31/2006  1.237048868
    11/1/2006   -0.784592691
    11/2/2006   2.737788889
    11/3/2006   0.575772221
    11/6/2006   0.756429404
    11/7/2006   3.470072539
    11/8/2006   3.162250037
    11/9/2006   3.530282875
    11/10/2006  3.101909259
    11/13/2006  3.850635629
    11/14/2006  5.765932269
    11/15/2006  6.872396495
    11/16/2006  7.65256188
    11/17/2006  7.665129818
    11/20/2006  7.688611466
    11/21/2006  10.98556762
    11/22/2006  10.3474519
    11/23/2006  8.307676877
    11/24/2006  6.809710616
    11/27/2006  3.833060531
    11/28/2006  2.194899225
    11/29/2006  2.753858429
    11/30/2006  7.843689893
    12/1/2006   7.960285607
    12/4/2006   8.693168009
    12/5/2006   6.942631629
    12/6/2006   7.571515106
    12/7/2006   9.703434772
    12/8/2006   9.330900226
    12/11/2006  10.07080936
    12/12/2006  8.823865383
    12/13/2006  9.142372346
    12/14/2006  11.4249828
    12/15/2006  13.4976679
    12/18/2006  16.02891813
    12/19/2006  13.57689804
    12/20/2006  13.08135113
    12/21/2006  11.35585478
    12/22/2006  11.56407075
    12/25/2006  12.55729202
    12/26/2006  12.74006864
    12/27/2006  12.80879851
    12/28/2006  12.78104782
    12/29/2006  10.84853655
    1/1/2007    12.34247778
    1/2/2007    12.4083186
    1/3/2007    12.05157619
    1/4/2007    13.31470937
    1/5/2007    13.08023063
    1/8/2007    11.8083914
    1/9/2007    12.14102299
    1/10/2007   12.78561441
    1/11/2007   10.5599935
    1/12/2007   9.670640578
    1/15/2007   7.5265463
    1/16/2007   5.785317873
    1/17/2007   6.421764885
    1/18/2007   6.13308998
    1/19/2007   4.502378909
    1/22/2007   5.18285115
    1/23/2007   6.651267567
    1/24/2007   9.669499091
    1/25/2007   9.873389316
    1/26/2007   8.512393515
    1/29/2007   8.17935067
    1/30/2007   7.565247724
    1/31/2007   10.26027855
    2/1/2007    12.21138996
    2/2/2007    11.0873071
    2/5/2007    15.28502878
    2/6/2007    13.68842955
    2/7/2007    13.27807961
    2/8/2007    12.83276901
    2/9/2007    13.80840316
    2/12/2007   10.40760837
    2/13/2007   8.706916548
    2/14/2007   7.062821439
    2/15/2007   6.720750572
    2/16/2007   5.181412914
    2/19/2007   6.377711852
    2/20/2007   6.777151257
    2/21/2007   7.213968623
    2/22/2007   5.717975255
    2/23/2007   7.535619266
    2/26/2007   6.226846924
    2/27/2007   6.420469572
    2/28/2007   7.825909152
    3/1/2007    9.322928614
    3/2/2007    10.09251084
    3/5/2007    10.01940332
    3/6/2007    8.500303192
    3/7/2007    8.276245994
    3/8/2007    8.618637579
    3/9/2007    9.130646064
    3/12/2007   5.00975105
    3/13/2007   3.332393527
    3/14/2007   1.483827461
    3/15/2007   3.638824916
    3/16/2007   3.461569024
    3/19/2007   2.163572694
    3/20/2007   2.369195247
    3/21/2007   -3.015080521
    3/22/2007   -2.584981113
    3/23/2007   1.616297026
    3/26/2007   3.424344952
    3/27/2007   3.512629879
    3/28/2007   1.565564369
    3/29/2007   3.155875359
    3/30/2007   4.13585074
    4/2/2007    2.121894843
    4/3/2007    2.85329683
    4/4/2007    2.790940846
    4/5/2007    2.709380118
    4/6/2007    -0.537294118
    4/9/2007    1.409591457
    4/10/2007   -0.844805873
    4/11/2007   -3.199042638
    4/12/2007   -5.222678135
    4/13/2007   -5.360018022
    4/16/2007   -4.086590776
    4/17/2007   -6.846401327
    4/18/2007   -8.129698699
    4/19/2007   -9.43907148
    4/20/2007   -9.54782865
    4/23/2007   -10.0618768
    4/24/2007   -7.849914365
    4/25/2007   -8.470629566
    4/26/2007   -8.241284473
    4/27/2007   -5.784288072
    4/30/2007   -6.333447193
    5/1/2007    -8.855330907
    5/2/2007    -8.631907451
    5/3/2007    -9.548866116
    5/4/2007    -10.13722709
    5/7/2007    -11.32424337
    5/8/2007    -13.57236374
    5/9/2007    -11.50262124
    5/10/2007   -10.80211768
    5/11/2007   -10.26422821
    5/14/2007   -8.986010695
    5/15/2007   -10.63105462
    5/16/2007   -12.91613223
    5/17/2007   -10.43330955
    5/18/2007   -10.07261057
    5/21/2007   -12.94116388
    5/22/2007   -11.97531943
    5/23/2007   -12.58290308
    5/24/2007   -12.94199083
    5/25/2007   -14.38311469
    5/28/2007   -13.28631254
    5/29/2007   -12.89413624
    5/30/2007   -16.04739138
    5/31/2007   -13.83259156
    6/1/2007    -14.26299611
    6/4/2007    -14.99654576
    6/5/2007    -13.24079702
    6/6/2007    -12.01283208
    6/7/2007    -12.58499189
    6/8/2007    -10.50548575
    6/11/2007   -13.46398497
    6/12/2007   -10.95636348
    6/13/2007   -10.58475154
    6/14/2007   -8.485156989
    6/15/2007   -5.485141673
    6/18/2007   -4.746107027
    6/19/2007   0.009767635
    6/20/2007   -0.673658716
    6/21/2007   -1.451419275
    6/22/2007   1.972232158
    6/25/2007   -0.391243872
    6/26/2007   1.451989507
    6/27/2007   -1.766451879
    6/28/2007   0.161875559
    6/29/2007   -3.825996412
    7/2/2007    -0.809421674
    7/3/2007    -2.246492588
    7/4/2007    0.432136714
    7/5/2007    0.283847174
    7/6/2007    -1.3650488
    7/9/2007    -0.811143411
    7/10/2007   -1.465879459
    7/11/2007   -1.121273878
    7/12/2007   -1.860874059
    7/13/2007   -3.035369125
    7/16/2007   1.281001022
    7/17/2007   1.690991572
    7/18/2007   1.945639351
    7/19/2007   1.069216233
    7/20/2007   3.87371198
    7/23/2007   3.296879921
    7/24/2007   2.591854823
    7/25/2007   -3.389010393
    7/26/2007   2.137825455
    7/27/2007   2.283479857
    7/30/2007   5.838696664
    7/31/2007   6.113554468
    8/1/2007    7.967210681
    8/2/2007    -0.726487682
    8/3/2007    -0.232469303
    8/6/2007    -2.517441263
    8/7/2007    -8.435316702
    8/8/2007    -4.850705516
    8/9/2007    -6.961937954
    8/10/2007   -10.44411748
    8/13/2007   -15.68807076
    8/14/2007   -13.18786164
    8/15/2007   -9.272095703
    8/16/2007   -4.725484174
    8/17/2007   -8.134541843
    8/20/2007   -8.873292727
    8/21/2007   -10.55565794
    8/22/2007   -9.78740166
    8/23/2007   -8.392234748
    8/24/2007   -11.26803991
    8/27/2007   -6.059253076
    8/28/2007   -4.431249471
    8/29/2007   -3.683881225
    8/30/2007   0.740388956
    8/31/2007   0.837060926
    9/3/2007    3.715197568
    9/4/2007    2.014739847
    9/5/2007    4.587444167
    9/6/2007    3.221048769
    9/7/2007    1.226037567
    9/10/2007   1.034531855
    9/11/2007   1.479676939
    9/12/2007   0.556376215
    9/13/2007   -1.530067312
    9/14/2007   -2.18203607
    9/17/2007   -5.475770938
    9/18/2007   -6.824996518
    9/19/2007   -2.973998241
    9/20/2007   3.708296857
    9/21/2007   -3.183077897
    9/24/2007   -6.546095221
    9/25/2007   -11.00709425
    9/26/2007   -10.95480863
    9/27/2007   -6.680893811
    9/28/2007   -3.787250701
    10/1/2007   -14.69643306
    10/2/2007   -12.37222197
    10/3/2007   -5.619971442
    10/4/2007   -5.695837937
    10/5/2007   -3.872021061
    10/8/2007   -5.852564553
    10/9/2007   -6.48262714
    10/10/2007  -2.398114024
    10/11/2007  -3.103357068
    10/12/2007  -5.878634994
    10/15/2007  -9.082817992
    10/16/2007  -6.07416967
    10/17/2007  -3.661138214
    10/18/2007  -1.840354785
    10/19/2007  -1.716032675
    10/22/2007  -9.940732878
    10/23/2007  -6.779819032
    10/24/2007  -9.55117772
    10/25/2007  -6.301075251
    10/26/2007  -4.727985653
    10/29/2007  -3.424320292
    10/30/2007  -7.488285236
    10/31/2007  -11.8982972
    11/1/2007   -15.03925521
    11/2/2007   -15.26744844
    11/5/2007   -14.74166075
    11/6/2007   -17.44941576
    11/7/2007   -17.61279378
    11/8/2007   -18.86796214
    11/9/2007   -16.67827827
    11/12/2007  -12.24014836
    11/13/2007  -2.85835521
    11/14/2007  -4.131716897
    11/15/2007  -0.203410622
    11/16/2007  8.569314879
    11/19/2007  5.520498128
    11/20/2007  4.437427097
    11/21/2007  2.798799233
    11/22/2007  5.190459646
    11/23/2007  2.201222838
    11/26/2007  7.707810591
    11/27/2007  5.20689008
    11/28/2007  7.610897036
    11/29/2007  6.703331237
    11/30/2007  13.92928613
    12/3/2007   18.05895477
    12/4/2007   17.24261674
    12/5/2007   14.18520991
    12/6/2007   17.69996813
    12/7/2007   21.95404938
    12/10/2007  18.57414126
    12/11/2007  18.83884342
    12/12/2007  22.41801362
    12/13/2007  23.54638194
    12/14/2007  25.76433638
    12/17/2007  16.69320167
    12/18/2007  10.81895687
    12/19/2007  10.9753503
    12/20/2007  11.33091315
    12/21/2007  12.53094339
    12/24/2007  14.45641754
    12/25/2007  13.19699079
    12/26/2007  13.87942316
    12/27/2007  11.46173706
    12/28/2007  7.770676488
    12/31/2007  8.700784022
    1/1/2008    14.19019359
    1/2/2008    11.50921642
    1/3/2008    9.467085019
    1/4/2008    8.492617897
    1/7/2008    5.371302597
    1/8/2008    6.499502146
    1/9/2008    3.022727189
    1/10/2008   5.927807015
    1/11/2008   5.001251384
    1/14/2008   0.091578188
    1/15/2008   6.806397951
    1/16/2008   2.248016175
    1/17/2008   5.749742329
    1/18/2008   1.095388248
    1/21/2008   -0.368023403
    1/22/2008   8.237992918
    1/23/2008   -0.780766435
    1/24/2008   -0.233793677
    1/25/2008   -5.104415967
    1/28/2008   -5.638624718
    1/29/2008   -2.511924819
    1/30/2008   -2.133339717
    1/31/2008   -3.014162532
    2/1/2008    4.847211419
    2/4/2008    1.90534583
    2/5/2008    -0.089019867
    2/6/2008    -3.930920283
    2/7/2008    -7.596390602
    2/8/2008    -5.358477963
    2/11/2008   -3.588291865
    2/12/2008   -1.031121178
    2/13/2008   4.176705555
    2/14/2008   4.100989501
    2/15/2008   3.685820292
    2/18/2008   3.918671965
    2/19/2008   4.302039738
    2/20/2008   8.143021699
    2/21/2008   7.475478645
    2/22/2008   2.322549449
    2/25/2008   5.058904324
    2/26/2008   0.911568809
    2/27/2008   -1.720405845
    2/28/2008   -4.566637975
    2/29/2008   -7.874776755
    3/3/2008    -7.949385894
    3/4/2008    -7.987067299
    3/5/2008    -12.40581822
    3/6/2008    -9.860569783
    3/7/2008    -12.72461433
    3/10/2008   -11.14026753
    3/11/2008   -6.222506019
    3/12/2008   -2.083816629
    3/13/2008   -1.722946088
    3/14/2008   -5.537069436
    3/17/2008   -6.716071481
    3/18/2008   -6.693944594
    3/19/2008   5.819147828
    3/20/2008   9.65059264
    3/21/2008   14.9915837
    3/24/2008   14.39795771
    3/25/2008   12.093442
    3/26/2008   9.296061707
    3/27/2008   12.99072309
    3/28/2008   9.836902201
    3/31/2008   9.921155178
    4/1/2008    7.310883267
    4/2/2008    14.15477406
    4/3/2008    15.48242329
    4/4/2008    7.464041165
    4/7/2008    11.33508368
    4/8/2008    15.59010551
    4/9/2008    12.58380558
    4/10/2008   14.61160039
    4/11/2008   12.68080501
    4/14/2008   11.06353488
    4/15/2008   7.092636692
    4/16/2008   7.592291792
    4/17/2008   3.699266022
    4/18/2008   5.928888483
    4/21/2008   9.133551847
    4/22/2008   6.211128385
    4/23/2008   5.59943155
    4/24/2008   11.19533502
    4/25/2008   8.286268131
    4/28/2008   10.85713699
    4/29/2008   10.96304626
    4/30/2008   9.392330251
    5/1/2008    0.459398303
    5/2/2008    6.634717801
    5/5/2008    7.475896399
    5/6/2008    6.934371007
    5/7/2008    5.570514268
    5/8/2008    6.270557437
    5/9/2008    7.889956448
    5/12/2008   1.34341901
    5/13/2008   -1.824946933
    5/14/2008   -1.801607848
    5/15/2008   -2.846939297
    5/16/2008   -2.62131888
    5/19/2008   -2.663214031
    5/20/2008   -3.774870813
    5/21/2008   -5.138174533
    5/22/2008   -5.480107155
    5/23/2008   -6.670996157
    5/26/2008   -4.64561419
    5/27/2008   -4.145292498
    5/28/2008   0.355057164
    5/29/2008   -2.939764523
    5/30/2008   -6.63747287
    6/2/2008    -6.098950421
    6/3/2008    -7.13882023
    6/4/2008    -5.604616952
    6/5/2008    -4.549857994
    6/6/2008    5.087697562
    6/9/2008    6.579771782
    6/10/2008   0.060955293
    6/11/2008   2.445348204
    6/12/2008   0.317989372
    6/13/2008   3.251865221
    6/16/2008   6.862732095
    6/17/2008   -0.134582166
    6/18/2008   -6.537950835
    6/19/2008   -8.448799147
    6/20/2008   -6.732406995
    6/23/2008   -7.738394975
    6/24/2008   -8.206195168
    6/25/2008   -5.548307148
    6/26/2008   -7.002765304
    6/27/2008   -6.495980763
    6/30/2008   -8.8477976
    7/1/2008    -1.679587243
    7/2/2008    0.128504075
    7/3/2008    -0.255570561
    7/4/2008    3.108701207
    7/7/2008    5.492404862
    7/8/2008    3.133532773
    7/9/2008    2.385568794
    7/10/2008   -3.712475585
    7/11/2008   -2.11874535
    7/14/2008   -7.791149245
    7/15/2008   -9.785882826
    7/16/2008   -16.1405786
    7/17/2008   -14.74751549
    7/18/2008   -13.27703399
    7/21/2008   -14.20650424
    7/22/2008   -16.05642567
    7/23/2008   -10.40258214
    7/24/2008   -7.895783574
    7/25/2008   -6.064576168
    7/28/2008   -7.555469117
    7/29/2008   -7.550365786
    7/30/2008   -4.41096581
    7/31/2008   0.972694457
    8/1/2008    -3.909922199
    8/4/2008    -2.854671378
    8/5/2008    -4.752925064
    8/6/2008    7.894333599
    8/7/2008    6.952958366
    8/8/2008    6.803337004
    8/11/2008   12.5598522
    8/12/2008   17.02711995
    8/13/2008   11.21457308
    8/14/2008   9.870340669
    8/15/2008   13.52048273
    8/18/2008   15.36663294
    8/19/2008   12.06804629
    8/20/2008   10.90150334
    8/21/2008   9.740240549
    8/22/2008   5.754842321
    8/25/2008   5.094710468
    8/26/2008   4.298242012
    8/27/2008   3.633974039
    8/28/2008   2.662183974
    8/29/2008   2.274767726
    9/1/2008    3.049897094
    9/2/2008    3.728150019
    9/3/2008    3.568469208
    9/4/2008    3.118192613
    9/5/2008    0.208336992
    9/8/2008    -7.955346446
    9/9/2008    3.034657287
    9/10/2008   0.212924163
    9/11/2008   -5.039089706
    9/12/2008   -4.206315664
    9/15/2008   -12.47329445
    9/16/2008   -23.87744975
    9/17/2008   -26.40484165
    9/18/2008   -25.38241597
    9/19/2008   -23.36121528
    9/22/2008   -21.42741971
    9/23/2008   -17.99846112
    9/24/2008   -28.57986509
    9/25/2008   -29.16609299
    9/26/2008   -27.08038434
    9/29/2008   -20.97454917
    9/30/2008   -30.86583486
    10/1/2008   -11.34463183
    10/2/2008   -12.48376615
    10/3/2008   -6.026656168
    10/6/2008   -6.990288682
    10/7/2008   -8.932722825
    10/8/2008   -9.613027881
    10/9/2008   -9.639879581
    10/10/2008  -9.585152864
    10/13/2008  -3.406342217
    10/14/2008  8.128268033
    10/15/2008  -0.84337937
    10/16/2008  3.021563746
    10/17/2008  -3.052518135
    10/20/2008  -2.400985986
    10/21/2008  3.0230433
    10/22/2008  10.5804596
    10/23/2008  18.09790623
    10/24/2008  12.13621658
    10/27/2008  14.20662326
    10/28/2008  21.01635274
    10/29/2008  17.2248841
    10/30/2008  -4.561706872
    10/31/2008  -18.90903769
    11/3/2008   -4.608843616
    11/4/2008   -20.06787313
    11/5/2008   -18.5941511
    11/6/2008   -21.3287201
    11/7/2008   -18.90428072
    11/10/2008  -17.15139132
    11/11/2008  -11.95485141
    11/12/2008  -10.52108832
    11/13/2008  -3.751031577
    11/14/2008  -7.025476067
    11/17/2008  -0.484754776
    11/18/2008  -7.565724121
    11/19/2008  -3.494100907
    11/20/2008  1.878346526
    11/21/2008  8.620226332
    11/24/2008  -2.178445463
    11/25/2008  -6.594895809
    11/26/2008  -13.80582831
    11/27/2008  -1.718399396
    11/28/2008  -2.690040888
    12/1/2008   0.045615029
    12/2/2008   -8.037898361
    12/3/2008   -6.694808104
    12/4/2008   -1.105754753
    12/5/2008   1.02570118
    12/8/2008   -4.239560375
    12/9/2008   -5.393379841
    12/10/2008  -2.751561124
    12/11/2008  -2.779615506
    12/12/2008  -3.187906517
    12/15/2008  -1.152777608
    12/16/2008  -8.701242176
    12/17/2008  -17.74161255
    12/18/2008  -25.91607496
    12/19/2008  -23.78881822
    12/22/2008  -21.24675823
    12/23/2008  -11.96460548
    12/24/2008  -15.00820918
    12/25/2008  -18.71378165
    12/26/2008  -15.66724025
    12/29/2008  -9.785209077
    12/30/2008  -8.555974407
    12/31/2008  -8.218782102

import pandas as pd
df=read_csv("Randomdata.csv")
df2=df.add(1).cumprod()

我也尝试了另一种方法。

df3=1+df.cumprod()

两者都产生-inf值。专门针对此数据集。 请提出前进的方向。

1 个答案:

答案 0 :(得分:1)

您似乎正在尝试计算累计收益。如果是这样,则这些数字不在返回空间中,需要先除以100

import pandas as pd

df = pd.read_csv("Randomdata.csv")
df2 = df.div(100).add(1).cumprod().sub(1).mul(100)

OP的评论

我进行了以下更改,删除了减法。

df2 = df.div(100).add(1).cumprod().mul(100)
df2['returns_from_price_recovered'] = 100 * df2.pct_change()