Skip to main content

Implementation of the SwingingDoor algorithm in Python.

Project description

License Release Supported versions Docs Code Coverage Build status Appveyor Build Status Travis CI Contact Blog

Swinging Door

Implementation of the SwingingDoor algorithm in Python.

Example of usage

>>> from datetime import datetime
>>> from pandas import read_csv, DataFrame

>>> df = DataFrame(
...     [
...         {
...             "Date": datetime.strptime(date, "%Y-%m-%d"),
...             "Price": value
...         }
...         for date, value in read_csv(
...             "https://datahub.io/core/oil-prices/r/wti-daily.csv"
...         ).values.tolist()
...     ]
... )

>>> print(len(df))
9286

>>> df.plot(x="Date", y="Price")
>>> from swinging_door import swinging_door

>>> compress = DataFrame(
...      list(
...         {
...             "Date": datetime.fromtimestamp(date),
...             "Price": value
...         }
...         for date, value in swinging_door(
...             [
...                 (date.timestamp(), value)
...                 for date, value in df.values.tolist()
...             ], deviation=.5
...         )
...     )
... )

>>> print(len(compress))
2719

>>> compress.plot(x="Date", y="Price")

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

swinging_door-1.0.1.tar.gz (4.3 kB view hashes)

Uploaded Source

Built Distribution

swinging_door-1.0.1-py3-none-any.whl (5.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