Skip to main content

TimeDataModel

A lightweight Pythonic data model for time series data, interoperable with NumPy, Pandas and Polars.

License: MIT PyPI version Python Versions GitHub Repo stars


TimeDataModel is a metadata-rich container for time series data. It lets you carry your data and its context — name, unit, frequency, timezone — as a single, self-describing object, fully interoperable with pandas, NumPy, Polars, and PyArrow.

⬇️ Installation  |  📖 Documentation  |  🚀 Examples


🧱 Core Data Classes

Class Description
📈 TimeSeries Univariate time series supporting four temporal shapes; the underlying DataFrame is optional, so the same class also serves as a metadata-only descriptor for catalog/registration use
🔷 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: ACTUALOBSERVATION, DERIVED; CALCULATEDFORECAST, SIMULATION, …
🗺️ GeoLocation / GeoArea Geographic point and polygon types with distance, bearing, and containment

📐 Data Shapes

TimeSeries supports four temporal shapes to model everything from simple point-in-time data to full audit trails:

Shape Columns Use case
SIMPLE valid_time, value Standard time series
VERSIONED knowledge_time, valid_time, value 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 TimeSeries, 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 = TimeSeries.from_pandas(
    df,
    frequency=Frequency.PT1H,
    name="wind_power",
    unit="MW",
)

print(ts)
# TimeSeries ─────────────────────────
#   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
cols   = ts.to_list()         # dict[str, list] — column-oriented
arr    = ts.to_numpy()        # dict[str, np.ndarray] — column-oriented (requires numpy)
tbl    = ts.to_pyarrow()      # pa.Table (requires pyarrow)

✨ Key Features

  • 🔷 Four data shapes — from SIMPLE point-in-time to AUDIT full audit history;
  • 🏷️ Metadata — name, unit, frequency, timezone, data type, description on every series;
  • 📋 Metadata-only mode — construct TimeSeries(df=None, …) to declare a series' structure before any data exists, for catalog/registration use;
  • 🔄 Format conversionsto_pandas, to_polars, to_list, to_numpy, to_pyarrow with lazy optional-dependency checks;
  • 📊 Coverage barcoverage_bar() renders null coverage as a binned SVG in Jupyter or Unicode blocks in terminal;
  • 🗺️ Geospatial primitivesGeoLocation and GeoArea for use by consumer layers;
  • 📏 Units — optional pint integration for dimensional unit conversion and validation;
  • Polars-powered — backed by the Polars compute engine for high-performance in-memory processing;
  • 🐍 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]

🤝 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.

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

timedatamodel-0.8.1.tar.gz (45.5 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

timedatamodel-0.8.1-py3-none-any.whl (31.1 kB view details)

Uploaded Python 3

File details

Details for the file timedatamodel-0.8.1.tar.gz.

File metadata

  • Download URL: timedatamodel-0.8.1.tar.gz
  • Upload date:
  • Size: 45.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for timedatamodel-0.8.1.tar.gz
Algorithm Hash digest
SHA256 e2d9180a7a843aecb5772915291cfc4991bd0de52f49805a3bbec08f0de37b47
MD5 6e1bbc0b1a6f2d500ad1f2c974d6be0f
BLAKE2b-256 467de4e3b5387489bd1a13e470421e6a67c12349021a898c56b212bc60014f4d

See more details on using hashes here.

Provenance

The following attestation bundles were made for timedatamodel-0.8.1.tar.gz:

Publisher: publish.yml on rebase-energy/timedatamodel

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file timedatamodel-0.8.1-py3-none-any.whl.

File metadata

  • Download URL: timedatamodel-0.8.1-py3-none-any.whl
  • Upload date:
  • Size: 31.1 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for timedatamodel-0.8.1-py3-none-any.whl
Algorithm Hash digest
SHA256 ac480652a5f6bb9c7b8abe627abcba0427d4172905186c6cb6c6b97011becf45
MD5 fa50c956a57eead6a1d58cba948b56c2
BLAKE2b-256 4f9c1f365a386ab97ed835523cd8753851210a98a4a48eb6a1383f5bf7f16fe3

See more details on using hashes here.

Provenance

The following attestation bundles were made for timedatamodel-0.8.1-py3-none-any.whl:

Publisher: publish.yml on rebase-energy/timedatamodel

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Release history Release notifications | RSS feed

0.11.0

2 files

0.10.0

2 files

0.9.0

2 files

This release

0.8.1 This release

2 files

0.8.0

2 files

0.7.0

2 files

0.6.0

2 files

0.5.0

2 files

0.3.0

2 files

0.2.2

2 files

0.2.0

2 files

0.1.9

2 files

0.1.8

2 files

0.1.7

2 files

0.1.6

2 files

0.1.5

2 files

0.1.4

2 files

0.1.3

2 files

0.1.2

2 files

0.1.1

2 files

0.1.0

2 files

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page