{
  "id": 93520,
  "title": "Help!",
  "url": "/competitions/LANL-Earthquake-Prediction/discussion/93520",
  "author_name": "",
  "post_date": "2019-05-27T22:08:26.109150100Z",
  "votes": -1,
  "comment_count": 6,
  "views": 0,
  "content": "<p>I need help applying a function over a moving window. How to do this? Suppose I have an array shape of (n, m) and I need to apply a function lets say mean, std, min, max, etc. to a window of 10. What is the code? I need an output array of length of 1000, each containing the function applied over the 10 period hypothetical window. Is there a numpy function for this? Thanks!</p>\n\n<p>consider array:</p>\n\n<p>&gt; np.ones(10000)</p>\n\n<p><strong>Full Disclosure</strong>: I'm also participating in a kaggle research study so I need a couple of instances where I asked for help and received it. </p>",
  "messages": [
    {
      "id": "537937",
      "postDate": "05/27/2019 22:08:26",
      "content": "<p>I need help applying a function over a moving window. How to do this? Suppose I have an array shape of (n, m) and I need to apply a function lets say mean, std, min, max, etc. to a window of 10. What is the code? I need an output array of length of 1000, each containing the function applied over the 10 period hypothetical window. Is there a numpy function for this? Thanks!</p>\n\n<p>consider array:</p>\n\n<p>&gt; np.ones(10000)</p>\n\n<p><strong>Full Disclosure</strong>: I'm also participating in a kaggle research study so I need a couple of instances where I asked for help and received it. </p>",
      "rawMarkdown": "I need help applying a function over a moving window. How to do this? Suppose I have an array shape of (n, m) and I need to apply a function lets say mean, std, min, max, etc. to a window of 10. What is the code? I need an output array of length of 1000, each containing the function applied over the 10 period hypothetical window. Is there a numpy function for this? Thanks!\n\nconsider array:\n\n&gt; np.ones(10000)\n\n\n\n__Full Disclosure__: I'm also participating in a kaggle research study so I need a couple of instances where I asked for help and received it.",
      "votes": null
    },
    {
      "id": "537941",
      "postDate": "05/27/2019 22:16:27",
      "content": "<p>If you don't write your own moving window computation, try the pandas.DataFrame.rolling:\n<a href=\"https://pandas.pydata.org/pandas-docs/stable/reference/api/pandas.DataFrame.rolling.html\">https://pandas.pydata.org/pandas-docs/stable/reference/api/pandas.DataFrame.rolling.html</a></p>\n\n<p>For example, <code>df.rolling(2).sum()</code>. </p>",
      "rawMarkdown": "If you don't write your own moving window computation, try the pandas.DataFrame.rolling:\nhttps://pandas.pydata.org/pandas-docs/stable/reference/api/pandas.DataFrame.rolling.html\n\nFor example, `df.rolling(2).sum()`.",
      "votes": null
    },
    {
      "id": "537942",
      "postDate": "05/27/2019 22:19:19",
      "content": "<p>Thank you. I think I'm going to try <a href=\"https://rigtorp.se/2011/01/01/rolling-statistics-numpy.html\">a custom function</a></p>",
      "rawMarkdown": "Thank you. I think I'm going to try [a custom function](https://rigtorp.se/2011/01/01/rolling-statistics-numpy.html)",
      "votes": null
    },
    {
      "id": "538133",
      "postDate": "05/28/2019 07:44:40",
      "content": "<p>You can do a custom function using rolling\nHere is an example <a href=\"https://www.kaggle.com/scirpus/earthquake-gp-filter\">https://www.kaggle.com/scirpus/earthquake-gp-filter</a>\nYou are mad not to use rolling in pandas as this is performance optimized.  Writing it from scratch is a bit of a waste of time IMHO.</p>",
      "rawMarkdown": "You can do a custom function using rolling\nHere is an example https://www.kaggle.com/scirpus/earthquake-gp-filter\nYou are mad not to use rolling in pandas as this is performance optimized.  Writing it from scratch is a bit of a waste of time IMHO.",
      "votes": null
    },
    {
      "id": "538159",
      "postDate": "05/28/2019 08:43:57",
      "content": "<p>Thank you. Do you have any basic benchmarks performed verifying this claim? I'm not doubting you, just, healthy skepticism ;). The only thing I really need is the implementation of a variable stride, and the ability to modify the datatype of the rolling output. I've ran into memory issues with certain functions, and high window sizes.</p>",
      "rawMarkdown": "Thank you. Do you have any basic benchmarks performed verifying this claim? I'm not doubting you, just, healthy skepticism ;). The only thing I really need is the implementation of a variable stride, and the ability to modify the datatype of the rolling output. I've ran into memory issues with certain functions, and high window sizes.",
      "votes": null
    },
    {
      "id": "538173",
      "postDate": "05/28/2019 09:10:01",
      "content": "<p>You could look at pandas code as it is open source.</p>\n\n<p>Start here for roll your own <a href=\"https://stackoverflow.com/questions/25583494/faster-rolling-apply-on-a-pandas-dataframe\">https://stackoverflow.com/questions/25583494/faster-rolling-apply-on-a-pandas-dataframe</a> (pun intended)</p>",
      "rawMarkdown": "You could look at pandas code as it is open source.\n\nStart here for roll your own https://stackoverflow.com/questions/25583494/faster-rolling-apply-on-a-pandas-dataframe (pun intended)",
      "votes": null
    },
    {
      "id": "539287",
      "postDate": "05/29/2019 20:35:24",
      "content": "<p>Weird how my question and request for help could get downvoted. I'm guessing it's someone who found it jeapordizing their chance at winning. That's good to know.</p>",
      "rawMarkdown": "Weird how my question and request for help could get downvoted. I'm guessing it's someone who found it jeapordizing their chance at winning. That's good to know.",
      "votes": null
    }
  ],
  "comments": [
    {
      "id": 537941,
      "author_name": "pukkinming",
      "author_url": "",
      "post_date": "05/27/2019 22:16:27",
      "content": "<p>If you don't write your own moving window computation, try the pandas.DataFrame.rolling:\n<a href=\"https://pandas.pydata.org/pandas-docs/stable/reference/api/pandas.DataFrame.rolling.html\">https://pandas.pydata.org/pandas-docs/stable/reference/api/pandas.DataFrame.rolling.html</a></p>\n\n<p>For example, <code>df.rolling(2).sum()</code>. </p>",
      "votes": null,
      "replies": [
        {
          "id": 537942,
          "author_name": "teeyee314",
          "author_url": "",
          "post_date": "05/27/2019 22:19:19",
          "content": "<p>Thank you. I think I'm going to try <a href=\"https://rigtorp.se/2011/01/01/rolling-statistics-numpy.html\">a custom function</a></p>",
          "votes": null,
          "replies": []
        }
      ]
    },
    {
      "id": 538133,
      "author_name": "scirpus",
      "author_url": "",
      "post_date": "05/28/2019 07:44:40",
      "content": "<p>You can do a custom function using rolling\nHere is an example <a href=\"https://www.kaggle.com/scirpus/earthquake-gp-filter\">https://www.kaggle.com/scirpus/earthquake-gp-filter</a>\nYou are mad not to use rolling in pandas as this is performance optimized.  Writing it from scratch is a bit of a waste of time IMHO.</p>",
      "votes": null,
      "replies": [
        {
          "id": 538159,
          "author_name": "teeyee314",
          "author_url": "",
          "post_date": "05/28/2019 08:43:57",
          "content": "<p>Thank you. Do you have any basic benchmarks performed verifying this claim? I'm not doubting you, just, healthy skepticism ;). The only thing I really need is the implementation of a variable stride, and the ability to modify the datatype of the rolling output. I've ran into memory issues with certain functions, and high window sizes.</p>",
          "votes": null,
          "replies": []
        },
        {
          "id": 538173,
          "author_name": "scirpus",
          "author_url": "",
          "post_date": "05/28/2019 09:10:01",
          "content": "<p>You could look at pandas code as it is open source.</p>\n\n<p>Start here for roll your own <a href=\"https://stackoverflow.com/questions/25583494/faster-rolling-apply-on-a-pandas-dataframe\">https://stackoverflow.com/questions/25583494/faster-rolling-apply-on-a-pandas-dataframe</a> (pun intended)</p>",
          "votes": null,
          "replies": []
        }
      ]
    },
    {
      "id": 539287,
      "author_name": "teeyee314",
      "author_url": "",
      "post_date": "05/29/2019 20:35:24",
      "content": "<p>Weird how my question and request for help could get downvoted. I'm guessing it's someone who found it jeapordizing their chance at winning. That's good to know.</p>",
      "votes": null,
      "replies": []
    }
  ],
  "raw_markdown_by_id": {
    "537937": "I need help applying a function over a moving window. How to do this? Suppose I have an array shape of (n, m) and I need to apply a function lets say mean, std, min, max, etc. to a window of 10. What is the code? I need an output array of length of 1000, each containing the function applied over the 10 period hypothetical window. Is there a numpy function for this? Thanks!\n\nconsider array:\n\n&gt; np.ones(10000)\n\n\n\n__Full Disclosure__: I'm also participating in a kaggle research study so I need a couple of instances where I asked for help and received it.",
    "537941": "If you don't write your own moving window computation, try the pandas.DataFrame.rolling:\nhttps://pandas.pydata.org/pandas-docs/stable/reference/api/pandas.DataFrame.rolling.html\n\nFor example, `df.rolling(2).sum()`.",
    "537942": "Thank you. I think I'm going to try [a custom function](https://rigtorp.se/2011/01/01/rolling-statistics-numpy.html)",
    "538133": "You can do a custom function using rolling\nHere is an example https://www.kaggle.com/scirpus/earthquake-gp-filter\nYou are mad not to use rolling in pandas as this is performance optimized.  Writing it from scratch is a bit of a waste of time IMHO.",
    "538159": "Thank you. Do you have any basic benchmarks performed verifying this claim? I'm not doubting you, just, healthy skepticism ;). The only thing I really need is the implementation of a variable stride, and the ability to modify the datatype of the rolling output. I've ran into memory issues with certain functions, and high window sizes.",
    "538173": "You could look at pandas code as it is open source.\n\nStart here for roll your own https://stackoverflow.com/questions/25583494/faster-rolling-apply-on-a-pandas-dataframe (pun intended)",
    "539287": "Weird how my question and request for help could get downvoted. I'm guessing it's someone who found it jeapordizing their chance at winning. That's good to know."
  },
  "source": "meta"
}