rolling_corr returns values > 1












1















I have a time series DataFrame which I would like to apply rolling_corr function with window = 3, but I found the some of the results were > 1. I guess it was due to the small changes in original values. Are there any workaround without modifying the original dataset?



       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


and the output:



        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


Update: taking larger window size could avoid the problem but I still wonder the cause and effect of the issue.










share|improve this question





























    1















    I have a time series DataFrame which I would like to apply rolling_corr function with window = 3, but I found the some of the results were > 1. I guess it was due to the small changes in original values. Are there any workaround without modifying the original dataset?



           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


    and the output:



            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


    Update: taking larger window size could avoid the problem but I still wonder the cause and effect of the issue.










    share|improve this question



























      1












      1








      1








      I have a time series DataFrame which I would like to apply rolling_corr function with window = 3, but I found the some of the results were > 1. I guess it was due to the small changes in original values. Are there any workaround without modifying the original dataset?



             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


      and the output:



              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


      Update: taking larger window size could avoid the problem but I still wonder the cause and effect of the issue.










      share|improve this question
















      I have a time series DataFrame which I would like to apply rolling_corr function with window = 3, but I found the some of the results were > 1. I guess it was due to the small changes in original values. Are there any workaround without modifying the original dataset?



             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


      and the output:



              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


      Update: taking larger window size could avoid the problem but I still wonder the cause and effect of the issue.







      pandas rolling-computation






      share|improve this question















      share|improve this question













      share|improve this question




      share|improve this question








      edited Jan 2 at 4:14







      Bohua

















      asked Jan 2 at 3:01









      BohuaBohua

      63




      63
























          0






          active

          oldest

          votes











          Your Answer






          StackExchange.ifUsing("editor", function () {
          StackExchange.using("externalEditor", function () {
          StackExchange.using("snippets", function () {
          StackExchange.snippets.init();
          });
          });
          }, "code-snippets");

          StackExchange.ready(function() {
          var channelOptions = {
          tags: "".split(" "),
          id: "1"
          };
          initTagRenderer("".split(" "), "".split(" "), channelOptions);

          StackExchange.using("externalEditor", function() {
          // Have to fire editor after snippets, if snippets enabled
          if (StackExchange.settings.snippets.snippetsEnabled) {
          StackExchange.using("snippets", function() {
          createEditor();
          });
          }
          else {
          createEditor();
          }
          });

          function createEditor() {
          StackExchange.prepareEditor({
          heartbeatType: 'answer',
          autoActivateHeartbeat: false,
          convertImagesToLinks: true,
          noModals: true,
          showLowRepImageUploadWarning: true,
          reputationToPostImages: 10,
          bindNavPrevention: true,
          postfix: "",
          imageUploader: {
          brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
          contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
          allowUrls: true
          },
          onDemand: true,
          discardSelector: ".discard-answer"
          ,immediatelyShowMarkdownHelp:true
          });


          }
          });














          draft saved

          draft discarded


















          StackExchange.ready(
          function () {
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f54000764%2frolling-corr-returns-values-1%23new-answer', 'question_page');
          }
          );

          Post as a guest















          Required, but never shown

























          0






          active

          oldest

          votes








          0






          active

          oldest

          votes









          active

          oldest

          votes






          active

          oldest

          votes
















          draft saved

          draft discarded




















































          Thanks for contributing an answer to Stack Overflow!


          • Please be sure to answer the question. Provide details and share your research!

          But avoid



          • Asking for help, clarification, or responding to other answers.

          • Making statements based on opinion; back them up with references or personal experience.


          To learn more, see our tips on writing great answers.




          draft saved


          draft discarded














          StackExchange.ready(
          function () {
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f54000764%2frolling-corr-returns-values-1%23new-answer', 'question_page');
          }
          );

          Post as a guest















          Required, but never shown





















































          Required, but never shown














          Required, but never shown












          Required, but never shown







          Required, but never shown

































          Required, but never shown














          Required, but never shown












          Required, but never shown







          Required, but never shown







          Popular posts from this blog

          MongoDB - Not Authorized To Execute Command

          How to fix TextFormField cause rebuild widget in Flutter

          in spring boot 2.1 many test slices are not allowed anymore due to multiple @BootstrapWith