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.2.tar.gz
(4.6 kB
view hashes)
Built Distribution
Close
Hashes for swinging_door-0.1.2-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 48cab6beadcac2093b22e81aa69d1b18503edda7153a96a4d090a6eaa5148164 |
|
MD5 | cc9493e068a66a83a335a4acbd8a5e18 |
|
BLAKE2b-256 | e64167f061637827013a6006c9e3b9e4406ab4cd53a44bbfae06c7646ec100cd |