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.0.tar.gz
(4.2 kB
view hashes)
Built Distribution
Close
Hashes for swinging_door-1.0.0-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 589d5a722ef84bd5488c2205bfd273fce4f4993c69cbecffca6cacee7771d6a9 |
|
MD5 | e31b5401e92c8c50c76737d7e0cbaa38 |
|
BLAKE2b-256 | 1ca2d1f1d13674eac2d915e05565c5457fbb5d6f4e07fe7db771a6ffccbb6ed8 |