{"id":22874869,"url":"https://github.com/jammyjamjamman/pywinslide","last_synced_at":"2025-03-31T12:44:07.914Z","repository":{"id":82846071,"uuid":"143212965","full_name":"Jammyjamjamman/PyWinSlide","owner":"Jammyjamjamman","description":"Sliding window functions for processing iterative timeseries data in python.","archived":false,"fork":false,"pushed_at":"2018-08-09T16:50:54.000Z","size":17,"stargazers_count":3,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-02-06T18:58:07.601Z","etag":null,"topics":["average","downsampling","mean","moving","resampling","rolling","sliding","timeseries","variance"],"latest_commit_sha":null,"homepage":null,"language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/Jammyjamjamman.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2018-08-01T22:02:49.000Z","updated_at":"2024-12-11T08:31:16.000Z","dependencies_parsed_at":null,"dependency_job_id":"534a2978-c35a-465f-b97b-e2c39fe156aa","html_url":"https://github.com/Jammyjamjamman/PyWinSlide","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Jammyjamjamman%2FPyWinSlide","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Jammyjamjamman%2FPyWinSlide/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Jammyjamjamman%2FPyWinSlide/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Jammyjamjamman%2FPyWinSlide/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Jammyjamjamman","download_url":"https://codeload.github.com/Jammyjamjamman/PyWinSlide/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":246472612,"owners_count":20783226,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["average","downsampling","mean","moving","resampling","rolling","sliding","timeseries","variance"],"created_at":"2024-12-13T14:40:18.126Z","updated_at":"2025-03-31T12:44:07.893Z","avatar_url":"https://github.com/Jammyjamjamman.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# PyWinSlide\nSliding window functions for processing iterative timeseries data in python.\n\nThis project is still in very early stages. If you need rolling window functions, I first recommend looking at rolling timeseries processing in [pandas dataframes](https://pandas.pydata.org/pandas-docs/stable/generated/pandas.DataFrame.rolling.html) .\n\n### Why you may/ may not want to use this script.\nThe reason I'm making this script as an alternative to the pandas rolling window, is that pandas requires the entire timeseries to be loaded into memory. The functions provided in this script allows data to be processed iteratively, which can reduce memory usage when compared to pandas. However, it is significantly slower than pandas at rolling calcuations.\n\n### What is supplied.\nCurrently, a generic `Window` class is provided and a `sliding_window` function for using the window class. These are for making new sliding window functions.\n\nUseable functions supplied are:\n\n* `sliding_mean_var()`, for calculating the rolling mean and variance within an iterative window.\n* `mean_downresample()`, for reducing the sample frequency of a timeseries e.g. every minute instead of every second, by taking the mean of the values every second within a minute window.\n\nTo create your own sliding window function, create a new class which inherits `Window`. To get the statistics you want from the window, override the method `get_cur_stats()`. Use the `sliding_window` function, and pass your `Window` class to the `Window_cls` argument.\n\n\n### Using The Script.\nThe easiest way to use the script currently, is to place `pywinslide.py` into the same directory as the script/ jupyter notebook you want to use it with. This is a following example of how to use it:\n\n```py\nimport pywinslide\n\n\"\"\"\nThe iterator 'timeseries_iter' should yield a tuple of the form (timestamp, number)\nevery iteration, in ascending time. N.B. The timestamp is a datetime object. The function does not handle\nNone types or other incorrect types.\n\"\"\"\n\n# Some timeseries iterator.\ntimeseries_iter = my_iter\n\n# Create lists of times, means and vars.\ntimes = []\nmeans = []\nvariances = []\n# Create and iterate through a rolling mean and variance function.\n# The size of the window is 1 day, which is also the default.\nfor time, mean, var in pywinslide.sliding_mean_var(timeseries_iter, window_sz=timedelta(days=1)):\n    times.append(time)\n    means.append(mean)\n    variances.append(var)\n```\n\n### Other Plans.\n* Add a jupyter notebook, demonstrating using this script.\n* Add more comments to the script.\n* I would really like to make cython versions of these functions in the future. However, I have no experience in using cython.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjammyjamjamman%2Fpywinslide","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fjammyjamjamman%2Fpywinslide","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjammyjamjamman%2Fpywinslide/lists"}