Implementation of the Swinging Door algorithm in Python.
Project description
Swinging Door
Implementation of the Swinging Door 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))
9895
>>> 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(
... iter(
... (date.timestamp(), value)
... for date, value in df.values.tolist()
... ), deviation=.5
... )
... )
... )
>>> print(len(compress))
3392
>>> 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-2.0.1.tar.gz
(4.5 kB
view details)
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file swinging_door-2.0.1.tar.gz.
File metadata
- Download URL: swinging_door-2.0.1.tar.gz
- Upload date:
- Size: 4.5 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.11.9
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
5680c4d60be20facda2c6383e18c113c5080f36855efbe3b37e1012e270a154b
|
|
| MD5 |
16654caaf362ce05e936465844fdb036
|
|
| BLAKE2b-256 |
25b76b076860773064d08d6a9d30e4d995c1d411386523f338cbf730d2e200d2
|
File details
Details for the file swinging_door-2.0.1-py3-none-any.whl.
File metadata
- Download URL: swinging_door-2.0.1-py3-none-any.whl
- Upload date:
- Size: 4.6 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.11.9
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
581fcbbaf026eaa31975f534e1d71abe9245bf604fb0ad4e1370221326b7c422
|
|
| MD5 |
50405335aab12f66bf3a4c8e01ee0bdc
|
|
| BLAKE2b-256 |
b50855de433017b747c628d6ec7e0f6be573f00f6a17217e8df5a2eb825652d6
|