Convinient statistical description of dataframes and time series.
This project has been archived.
The maintainers of this project have marked this project as archived. No new releases are expected.
Project description
Welcome to Stat Box рџ‘‹
A low-code python utility for fast statistics collection
Install
pip install stat-box
Usage
Statistics
from stat_box.statistic import StatisticSet, Quantile,
import pandas as pd
df = pd.DataFrame(
{"1": {"a": 1, "b": 2}, "2": {"a": 3, "b": 3}, "3": {"a": "1", "b": "d"}}
)
print(StatisticSet({Quantile(i / 100) for i in range(1, 100)}).stat_table(df))
# The same
print(QUANTILE_SET.stat_table(df))
Time series
from stat_box.time_series import TimeSeries, plot, group, rolling_trend, exp1, exp2, linear_trend, diff
import pandas as pd
from datetime import datetime
from dateutil.relativedelta import relativedelta
import numpy as np
# Generate data
data = pd.DataFrame(
{
"time": [datetime.now() + relativedelta(days=i) for i in range(365)],
"value": [
np.random.randint(-30, 30) + np.random.randint(-i / 7, i / 3 + 1)
for i in range(365)
],
}
)
# Indexed data
ts = TimeSeries(data)
ts.set_index('time')
plot(ts, title="Indexed data")
# Grouped data
gts = group(ts, "30d")
plot(gts, title="Grouped data")
# Rolling trend
rts = rolling_trend(ts, "30d")
plot(rts, title="Rolling trend")
# EXP_1
alpha = 0.02
e1ts = exp1(ts, alpha)
plot(e1ts, title=f"Exp_1 a trend (alpha = {alpha})")
# EXP_2
alpha = 0.6
beta = 0.9
e2ts = exp2(ts, alpha, beta)
plot(e2ts, title=f"Exp_2 a trend (alpha = {alpha} beta={beta})")
# Linear trend
lts = linear_trend(rts)
plot(lts, title="Linear trend")
# Diff
sdts = diff(rts, "sequential", True)
plot(sdts, title="Sequential diff of rolling data")
edts = diff(rts, "end", True)
plot(edts, title="End diff of rolling data")
ledrs = linear_trend(edts)
plot([edts, ledrs], legend=['edts', 'ledrs'], title="Linear trend of end dif of rolling data")
Author
👤 dmatryus
- Github: @dmatryus.sqrt49
рџ¤ќ Contributing
Contributions, issues and feature requests are welcome!
Feel free to check issues page. PRs are welcome!
Show your support
Give a вђпёЏ if this project helped you!
рџ“ќ License
Copyright В© 2021 dmatryus.
This project is MIT licensed.
This README was generated with вќ¤пёЏ by readme-md-generator
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
stat_box-0.1.4.post1.tar.gz
(9.6 kB
view details)
File details
Details for the file stat_box-0.1.4.post1.tar.gz.
File metadata
- Download URL: stat_box-0.1.4.post1.tar.gz
- Upload date:
- Size: 9.6 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.11.2
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
68a78292daffe21fa7e976aeae4e14263715cae7b58ae361ea50bcafbb10ec01
|
|
| MD5 |
234ae864af10a11b6cbb00466ee60375
|
|
| BLAKE2b-256 |
730b77c4d5579a240f53b43f1ab3763696cf66795ed1e45b2e495af0d6c0158f
|