Basic Usage
Creating a TimeSeries
from datetime import datetime
from timedatamodel import TimeSeries, Frequency
ts = TimeSeries(
Frequency.PT1H,
timestamps=[datetime(2024, 1, 1, h) for h in range(24)],
values=[float(h) for h in range(24)],
name="temperature",
unit="degC",
)
Converting to pandas / numpy
df = ts.df
arr = ts.arr
Arithmetic
ts_doubled = ts * 2
Integrations
Each class provides to_X, from_X, and apply_X bridges to popular array and dataframe libraries.
numpy |
pandas |
polars |
xarray |
|
|---|---|---|---|---|
TimeSeries |
||||
|
✅ |
✅ |
✅ |
✅ |
|
— |
✅ |
✅ |
✅ |
|
✅ |
✅ |
✅ |
✅ |
TimeSeriesTable |
||||
|
✅ |
✅ |
✅ |
✅ |
|
— |
✅ |
— |
✅ |
|
✅ |
✅ |
✅ |
✅ |
TimeSeriesArray |
||||
|
✅ |
✅ |
— |
✅ |
|
✅ |
— |
— |
✅ |
|
— |
✅¹ |
✅¹ |
✅ |
¹ Gated: raises ValueError if the array has more than 2 non-time dimensions.