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
>>> 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)
Built Distribution
Close
Hashes for swinging_door-1.0.1-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 2f46ac2eec7bb3fe8e56621f21645783556f8606eb104e44b488776168c817ce |
|
MD5 | bbaa2d395c615fae06f4c7031cbf0488 |
|
BLAKE2b-256 | f9332be01a2f0da6ef38b4b23030f86bed1de7e058e266efdcbbf6ef7febc344 |