Skip to main content
PolarsTS


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 PolarsTS


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 PolarsTS 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 file.

Metadata

Release files for pistachiots 0.1.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for pistachiots 0.1.0
File Size Uploaded
pistachiots-0.1.0.tar.gz 9.3 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for pistachiots 0.1.0
File Interpreter ABI Platform
pistachiots-0.1.0-py3-none-any.whl Python 3 none any Details

Total release size: 17.9 kB

Release files / pistachiots-0.1.0.tar.gz

Download URL pistachiots-0.1.0.tar.gz
Size 9.3 kB
Tags Source
SHA-256 checksum
How to use checksums
f3753a0bea972f37f62a0668ab66c290d05533ca9489ab12d1fb90f82b716ea9
BLAKE2b-256 checksum
How to use checksums
1b9c112d2ada75542de45724b611dcb4e55e1544257faad9afcf7412278c3d98
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.0-py3-none-any.whl

Download URL pistachiots-0.1.0-py3-none-any.whl
Size 8.6 kB
Tags Python 3
SHA-256 checksum
How to use checksums
a84e644af5765d74147ed3e495ba9b4e6b5628013c6b71b414c43fe285c7eb43
BLAKE2b-256 checksum
How to use checksums
41ea9320ddea07aef0e12782f83b85d6102d3c1abe34a4b19e2fcdd5e3b0b3fb
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.12.7

Release history Release notifications | RSS feed

0.1.1

2 release files

This release

0.1.0 This release

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page