pistachiots
Time series handling on top of polars: a TSPolars object that keeps track of
the time index and the panel keys, with methods for sorting, lagging,
differencing and validation.
This is an independent project, not affiliated with the polars development team.
INSTALLATION
pip install pistachiots
THE TSPOLARS OBJECT
TSPolars wraps a polars DataFrame and remembers three things: which column is
the time index (ts_col), which columns identify each series in a panel
(id_cols), and what kind of time step the index represents (ts_op).
import polars as pl
import pistachiots as cln
ts = cln.TSPolars(df, ts_col='fecha', id_cols=['region'], ts_op='yearmonth')
Valid values for ts_op: yearweek, yearmonth, yearquarter, date, datetime,
time, int.
Any polars method works directly on the object and returns a new TSPolars, so
the index and the keys survive the operation.
LAGS
add_lags creates lagged columns named L1x, L2x, and so on, computed within each
key so values never leak across series.
ts.add_lags(n_lags = 3)
ts.add_lags(var = 'ipc', n_lags = 6)
ts.add_lags(lags = {'ipc': 3, 'ventas': [1, 6, 12]})
rem_lags is the inverse and takes the same arguments.
OTHER METHODS
valid(keys_policy, n_keys_allowed) checks the object before using it
sort_ts(keys_first) sorts by keys and index
group_lags(response) puts each variable next to its lags
dif_vars(var) differences the given variables
format_ts_col() formats the index as text per ts_op
Every method takes inplace: with False (the default) it returns a new object,
with True it modifies the existing one.
LICENSE
MIT. See the LICENSE.txt file.
Metadata
Release files for pistachiots 0.1.1
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| pistachiots-0.1.1.tar.gz | 9.3 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| pistachiots-0.1.1-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 17.9 kB
Release files / pistachiots-0.1.1.tar.gz
| Download URL | pistachiots-0.1.1.tar.gz |
|---|---|
| Size | 9.3 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
fa80c2033ba83428b12d27ed09cb3f0ee32a6f2cb260313260487ba65d1e76fa
|
|
BLAKE2b-256 checksum How to use checksums |
47218a5526f06a4e42a7eaab13d5e513a60104901975103bb55788a2a0a0e408
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.12.7
|
Release files / pistachiots-0.1.1-py3-none-any.whl
| Download URL | pistachiots-0.1.1-py3-none-any.whl |
|---|---|
| Size | 8.6 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
5b5f66b3d80f1ec69365958b53a5d699e5871dd9a87e1f68f16735b2ad8abe7a
|
|
BLAKE2b-256 checksum How to use checksums |
7cd4d690a0575813302c7cea88c61d3a7c0a744b1d3f8dd7361ac7fff7f34f92
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.12.7
|