Implementation of the SwingingDoor algorithm in Python.
Project description
Swinging Door
Implementation of the SwingingDoor algorithm in Python.
Example of usage
>>> from datetime import datetime
>>> from pandas import read_csv, DataFrame
>>> def get_data(data):
... for date, value in data.values.tolist():
... yield datetime.strptime(date, "%Y-%m-%d").timestamp(), value
>>> df = read_csv("https://datahub.io/core/oil-prices/r/wti-daily.csv")
>>> print(len(df))
8737
>>> df.plot(x="Date", y="Price")
>>> from swinging_door import swinging_door
>>> compress = DataFrame(
... tuple(
... {
... "Date": datetime.fromtimestamp(date),
... "Price": value
... }
... for date, value in swinging_door(
... get_data(df), deviation=.5
... )
... )
... )
>>> print(len(compress))
2584
>>> 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-0.1.1.tar.gz
(4.6 kB
view hashes)
Built Distribution
Close
Hashes for swinging_door-0.1.1-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 7143989fb745c795230c9dc0f025bbefc9c2c0738fae66c8639f23ffdfc7700f |
|
MD5 | 240eea1c6cc9cd64afcda70be1245f8a |
|
BLAKE2b-256 | ced82e42cb828d0018692ce72372d9afba4478791f0da196bab99b050bad4ab2 |