我有一个时间序列DataFrame,我想在window = 3上应用rolling_corr函数,但是我发现其中一些结果>1。我猜这是由于原始值的微小变化所致。有没有不修改原始数据集的解决方法?
Index TA sn
2015-09-23 22:30:00 4923.866489 102730.000000
2015-09-23 22:35:00 4928.549856 102730.000000
2015-09-23 22:40:00 4933.126237 102730.000000
2015-09-23 22:45:00 4932.423757 102730.000000
2015-09-23 22:50:00 4930.632884 102730.000000
2015-09-23 22:55:00 4932.184794 102940.000000
2015-09-23 23:00:00 4925.654600 102840.000000
2015-09-24 09:00:00 4914.802897 102675.000000
2015-09-24 09:05:00 4897.657917 102477.142857
2015-09-24 09:10:00 4895.178979 102303.333333
2015-09-24 09:15:00 4893.134804 102435.000000
2015-09-24 09:20:00 4899.745662 102440.000000
2015-09-24 09:25:00 4902.197101 102500.000000
2015-09-24 09:30:00 4900.230251 102490.000000
2015-09-24 09:35:00 4895.271591 102600.000000
2015-09-24 09:40:00 4891.941444 102550.000000
2015-09-24 09:45:00 4885.363355 102550.000000
2015-09-24 09:50:00 4882.384047 102550.000000
2015-09-24 09:55:00 4884.698022 102550.000000
2015-09-24 10:00:00 4884.919459 102550.000000
2015-09-24 10:05:00 4882.617120 102550.000000
2015-09-24 10:10:00 4882.752606 102550.000000
2015-09-24 10:15:00 4883.183232 102550.000000
和输出:
Index rolling_corr
2015-09-23 22:30:00
2015-09-23 22:35:00
2015-09-23 22:40:00 -inf
2015-09-23 22:45:00 inf
2015-09-23 22:50:00 inf
2015-09-23 22:55:00 0.389793929698
2015-09-23 23:00:00 0.200596075192
2015-09-24 09:00:00 0.999998215741
2015-09-24 09:05:00 0.997050258267
2015-09-24 09:10:00 0.932322658978
2015-09-24 09:15:00 0.285942864418
2015-09-24 09:20:00 0.246531134353
2015-09-24 09:25:00 0.756098005938
2015-09-24 09:30:00 0.762718525006
2015-09-24 09:35:00 -0.935380177853
2015-09-24 09:40:00 -0.635755535941
2015-09-24 09:45:00 0.75794248422
2015-09-24 09:50:00 0.000867697788219
2015-09-24 09:55:00 0.00203505802058
2015-09-24 10:00:00 0.00151086403735
2015-09-24 10:05:00 0.00167037819182
2015-09-24 10:10:00 0.0
2015-09-24 10:15:00 0.0
更新:增大窗口大小可以避免此问题,但我仍然想知道问题的原因和结果。