A lightweight data model for time series data with pandas, numpy, and polars support
Project description
TimeDataModel is a metadata-rich, Polars-backed container for time series data. It lets you carry your data and its context — name, unit, frequency, timezone, location — as a single, self-describing object, while staying fully interoperable with pandas.
⬇️ Installation | 📖 Documentation | 🚀 Examples
🧱 Core Data Classes
| Class | Description |
|---|---|
📈 TimeSeriesPolars |
Univariate time series backed by a Polars DataFrame, supporting four temporal shapes |
📊 TimeSeriesTablePolars |
Multivariate time series — multiple named columns sharing the same valid_time index |
🔷 DataShape |
Enum that selects which timestamp columns are present: SIMPLE, VERSIONED, CORRECTED, or AUDIT |
⏱️ Frequency |
ISO 8601 duration-based frequencies (PT1H, P1D, P1M, …) |
🏷️ DataType |
Hierarchical taxonomy: ACTUAL → OBSERVATION, DERIVED; CALCULATED → FORECAST, SIMULATION, … |
🗺️ GeoLocation / GeoArea |
Geographic point and polygon types with distance, bearing, and containment |
📐 Data Shapes
TimeSeriesPolars supports four temporal shapes to model everything from simple point-in-time
data to fully bi-temporal audit trails:
| Shape | Columns | Use case |
|---|---|---|
SIMPLE |
valid_time, value |
Standard time series |
VERSIONED |
knowledge_time, valid_time, value |
Bi-temporal: track when each value was produced |
CORRECTED |
valid_time, change_time, value |
Corrections: track when a value was revised |
AUDIT |
knowledge_time, change_time, valid_time, value |
Full audit trail |
🚀 Quick Start
import pandas as pd
from timedatamodel import TimeSeriesPolars, TimeSeriesTablePolars, DataShape, Frequency
# --- Univariate series from a pandas DataFrame ---
df = pd.DataFrame({
"valid_time": pd.date_range("2024-01-01", periods=24, freq="h", tz="UTC"),
"value": [100.0 + i * 2.5 for i in range(24)],
})
ts = TimeSeriesPolars.from_pandas(
df,
shape=DataShape.SIMPLE,
frequency=Frequency.PT1H,
name="wind_power",
unit="MW",
)
print(ts)
# TimeSeriesPolars ─────────────────────────
# Name wind_power
# Shape SIMPLE
# Rows 24
# Frequency PT1H
# Timezone UTC
# Unit MW
# ──────────────────────────────────────────
# wind_power
# 2024-01-01 00:00 100.0
# 2024-01-01 01:00 102.5
# ...
# --- Unit conversion (requires pint extra) ---
ts_kw = ts.convert_unit("kW")
# --- Format conversions ---
df_pd = ts.to_pandas() # pd.DataFrame with datetime index
df_pl = ts.to_polars() # pl.DataFrame
rows = ts.to_python_list() # list[dict] — one dict per row
arr = ts.to_numpy() # structured np.ndarray (requires numpy)
tbl = ts.to_pyarrow() # pa.Table (requires pyarrow)
# --- Multivariate table — see examples/nb_02_timeseries_table_polars.ipynb ---
✨ Key Features
- 🔷 Four data shapes — from
SIMPLEpoint-in-time toAUDITfull bi-temporal history; - 🏷️ Rich metadata — name, unit, frequency, timezone, data type, location, labels, description on every series;
- 📊 Multivariate tables —
TimeSeriesTablePolarsgroups co-indexed series with per-column metadata; - 🔄 Format conversions —
to_pandas,to_polars,to_python_list,to_numpy,to_pyarrowwith lazy optional-dependency checks; - 📊 Coverage bar —
coverage_bar()renders null coverage as a binned SVG in Jupyter or Unicode blocks in terminal; - 🗺️ Geospatial — attach locations, filter by radius or area, find nearest columns;
- 📏 Units — optional pint integration for dimensional unit conversion;
- ⚡ Polars native — all internal operations use the Polars compute engine;
- 🐍 Type-safe — full type hints with PEP 561 support.
⬇️ Installation
Install the stable release:
pip install timedatamodel
Install with optional dependencies:
pip install timedatamodel[pandas] # pandas interop (includes pyarrow for tz-aware columns)
pip install timedatamodel[pint] # unit conversion
pip install timedatamodel[geo] # geospatial support (shapely)
pip install timedatamodel[all] # all optional extras
Install in editable mode for development:
git clone https://github.com/rebase-energy/TimeDataModel.git
cd TimeDataModel
pip install -e .[dev]
📓 Examples
| # | Notebook | Topic |
|---|---|---|
| 01 | TimeSeriesPolars | Creating, inspecting, and operating on univariate polars-backed time series |
| 02 | TimeSeriesTablePolars | Multivariate tables with per-column metadata and spatial filtering |
🤝 Contributing
Contributions are welcome! Here are some ways to contribute to TimeDataModel:
- Propose new features or extend existing classes;
- Improve documentation or add example notebooks;
- Report bugs or suggest features via GitHub Issues.
📄 Licence
This project uses the MIT Licence.
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
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 timedatamodel-0.1.5.tar.gz.
File metadata
- Download URL: timedatamodel-0.1.5.tar.gz
- Upload date:
- Size: 11.4 MB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
bb31d35df64e949da339a1a4acb87ad0e6ed8eb7fa012d3dc0ea16a5f500eecf
|
|
| MD5 |
dcfeef70606cb54419a01aea48818efb
|
|
| BLAKE2b-256 |
5a6d2fdbba0e28ebe38060e8511b6fbfe7fd40eaaa119dfdf8125ee6b91a2ade
|
Provenance
The following attestation bundles were made for timedatamodel-0.1.5.tar.gz:
Publisher:
publish.yml on rebase-energy/TimeDataModel
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
timedatamodel-0.1.5.tar.gz -
Subject digest:
bb31d35df64e949da339a1a4acb87ad0e6ed8eb7fa012d3dc0ea16a5f500eecf - Sigstore transparency entry: 1115304026
- Sigstore integration time:
-
Permalink:
rebase-energy/TimeDataModel@e967d9166bce79e5c3e609c1d1f9f672ab0c0821 -
Branch / Tag:
refs/tags/v0.1.5 - Owner: https://github.com/rebase-energy
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@e967d9166bce79e5c3e609c1d1f9f672ab0c0821 -
Trigger Event:
release
-
Statement type:
File details
Details for the file timedatamodel-0.1.5-py3-none-any.whl.
File metadata
- Download URL: timedatamodel-0.1.5-py3-none-any.whl
- Upload date:
- Size: 30.3 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
d572f881064a7c05c5dfa4311da66245309da0ea129b2841092d72a0ab2a505c
|
|
| MD5 |
a64cb3e8ae577f95abe35be0097b5b8c
|
|
| BLAKE2b-256 |
526658332290acf5619c198b0d002c29f16c968318ee191856b1f21f93a94bfa
|
Provenance
The following attestation bundles were made for timedatamodel-0.1.5-py3-none-any.whl:
Publisher:
publish.yml on rebase-energy/TimeDataModel
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
timedatamodel-0.1.5-py3-none-any.whl -
Subject digest:
d572f881064a7c05c5dfa4311da66245309da0ea129b2841092d72a0ab2a505c - Sigstore transparency entry: 1115304077
- Sigstore integration time:
-
Permalink:
rebase-energy/TimeDataModel@e967d9166bce79e5c3e609c1d1f9f672ab0c0821 -
Branch / Tag:
refs/tags/v0.1.5 - Owner: https://github.com/rebase-energy
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@e967d9166bce79e5c3e609c1d1f9f672ab0c0821 -
Trigger Event:
release
-
Statement type: