Skip to main content

Python implementation of a sliding window.

Project description

License Coverage Version

Time Series

A simple python implementation of a sliding window.

Installation

pip install time-series

Examples

import timeseries

# max 10 data points
fixed_window = timeseries.Fixed(10)

# removes added data points after 10 seconds
timer_window = timeseries.Timer(10)

# deletes data points after 10 iterations
for i in range(100):
    current_window = fixed_window.slide(i)

# deletes data points after 10 seconds have elapsed.
for i in range(100):
    current_window = timer_window.slide(i)

# prints 89...99
for i in fixed_window:
    print(i)

# will most likely print 0...99
for i in timer_window:
    print(i)

if fixed_window.is_full:
    print("fixed window is full")

# shrinks the number of elements to 2 (threadsafe)
fixed_window.maxsize = 2

# print current number of items
print(timer_window.size, len(timer_window))

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

time-series-0.2.tar.gz (2.3 kB view hashes)

Uploaded Source

Built Distribution

time_series-0.2-py3-none-any.whl (3.5 kB view hashes)

Uploaded Python 3

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page