Metadata-Version: 2.4
Name: pistachiots
Version: 0.1.0
Summary: Time series cleaning, lag handling and validation on top of polars
Author-email: Daniel José Aguilar Paniagua <danieljoseaguilar@gmail.com>
License: MIT
Keywords: time series,polars,lags,panel data,data cleaning
Classifier: Development Status :: 3 - Alpha
Classifier: Intended Audience :: Science/Research
Classifier: License :: OSI Approved :: MIT License
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.9
Classifier: Programming Language :: Python :: 3.10
Classifier: Programming Language :: Python :: 3.11
Classifier: Programming Language :: Python :: 3.12
Classifier: Topic :: Scientific/Engineering
Requires-Python: >=3.9
Description-Content-Type: text/plain
License-File: LICENSE.txt
Requires-Dist: polars
Dynamic: license-file

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.
