tstore package#
Subpackages#
- tstore.archive package
- tstore.tsdf package
- tstore.tsdt package
- tstore.tslong package
- tstore.tswide package
Submodules#
tstore.backend module#
Define possible backends for type hinting.
- tstore.backend.cast_column_to_large_string(df: DataFrame | GeoDataFrame | DataFrame | DataFrame | Table, col: str) DataFrame | GeoDataFrame | DataFrame | DataFrame | Table[source]#
Cast a column to a large string type.
- tstore.backend.change_backend(obj: T, new_backend: Literal['dask', 'geopandas', 'pandas', 'polars', 'pyarrow'], index_var: str | None = None, **backend_kwargs) T[source]#
Change the backend of a dataframe or a series.
If index_var is provided, the corresponding column is set as the index if the backend supports it. Otherwise, it is converted to a regular column (DataFrame) or dropped (Series).
- tstore.backend.get_backend(obj: T) Literal['dask', 'geopandas', 'pandas', 'polars', 'pyarrow'][source]#
Get the backend of a dataframe or a series.
- tstore.backend.get_column_names(df: DataFrame | GeoDataFrame | DataFrame | DataFrame | Table) list[str][source]#
Get the column names of a DataFrame.
- tstore.backend.get_dataframe_index(df: DataFrame | GeoDataFrame | DataFrame | DataFrame | Table) str | None[source]#
Get the name of the index of a DataFrame.
- tstore.backend.re_set_dataframe_index(df: DataFrame | GeoDataFrame | DataFrame | DataFrame | Table, index_var: str | None = None) DataFrame | GeoDataFrame | DataFrame | DataFrame | Table[source]#
Remove existing dataframe index and set a new one if index_var is provided.
Module contents#
tstore.
- class tstore.TS(df: DataFrame | GeoDataFrame | DataFrame | DataFrame | Table, time_var='time')[source]#
Bases:
objectTS object.
- change_backend(new_backend)[source]#
Return a new TS object with the dataframe converted to a different backend.
- property current_backend#
Return the backend of the wrapped dataframe.
- static from_disk(fpath, partitions, backend: Literal['dask', 'geopandas', 'pandas', 'polars', 'pyarrow'] = 'dask', columns=None, start_time=None, end_time=None, inclusive=None, split_row_groups=False, calculate_divisions=True, ignore_metadata_file=False, **kwargs)[source]#
Read a time series from disk into a Dask.DataFrame.
- class tstore.TSArray(data, copy: bool = False)[source]#
Bases:
ExtensionArrayAn ExtensionArray for TS objects, holding the array-based implementations.
- property dtype#
An instance of TSDtype.
- property nbytes: int#
The number of bytes needed to store this object in memory.
- property ts_class#
TS inner class.
- class tstore.TSDF(*args, **kwargs)[source]#
Bases:
TSWrapperWrapper for a DataFrame of TSArray objects.
- change_ts_backend(new_backend: Literal['dask', 'geopandas', 'pandas', 'polars', 'pyarrow'], ts_cols: list[str] | None = None) TSDF[source]#
Return a new TSDF object with dataframes wrapped in internal TS objects converted to a different backend.
- Parameters:
new_backend (Backend) – New backend to use for the TS objects.
ts_cols (Optional[list[str]]) – List of columns to convert. If None, convert all TS columns.
- static from_tstore(base_dir: str, backend: Literal['dask', 'geopandas', 'pandas', 'polars', 'pyarrow'] = 'dask') TSDF[source]#
Read TStore into TSDF object.
- get_ts_backend(ts_col: str) Literal['dask', 'geopandas', 'pandas', 'polars', 'pyarrow'][source]#
Return the current backend of a wrapped dataframe.
- to_tslong(backend: Literal['dask', 'geopandas', 'pandas', 'polars', 'pyarrow'] = 'dask') TSLong[source]#
Convert the wrapper into a TSLong object.
- to_tstore(base_dir, partitioning=None, tstore_structure='id-var', overwrite=True)[source]#
Write TStore from TSDF object.
- class tstore.TSDtype(ts_class=None)[source]#
Bases:
ExtensionDtypeAn ExtensionDtype for TS time series data.
- classmethod construct_from_string(string: str)[source]#
Construct an TSDtype from a string.
Example:#
>>> TSDtype.construct_from_string("TS[pandas]") TS['pandas']
- property name: str#
A string representation of the dtype.
- property ts_class: str#
The TS object class.
- class tstore.TSLong(*args, **kwargs)[source]#
Bases:
TSWrapperAbstract wrapper for a long-form timeseries DataFrame.
- change_backend(new_backend: Literal['dask', 'geopandas', 'pandas', 'polars', 'pyarrow']) TSLong[source]#
Return a new wrapper with the dataframe converted to a different backend.
- static wrap(self, df: DataFrame | GeoDataFrame | DataFrame | DataFrame | Table, id_var: str, time_var: str = 'time', ts_vars: dict[str, list[str]] | list[str] | None = None, static_vars: list[str] | None = None, geometry: GeoDataFrame | None = None) TSLong[source]#
Wrap a long-form timeseries DataFrame as a TSLong object.
- Parameters:
df (DataFrame) – DataFrame to wrap.
id_var (str) – Name of the column containing the identifier variable.
time_var (str) – Name of the column containing the time variable. Defaults to “time”.
ts_vars (Union[dict[str, list[str]], list[str], None]) – Dictionary of named groups of column names or list of column names (which will create one group per entry). Defaults to None, which will group all columns not in static_vars together under a group called “ts_variable”.
static_vars (Optional[list[str]]) – List of column names that are static across time. Defaults to None.
geometry (Optional[GeoPandasDataFrame]) – GeoPandas DataFrame containing geometry information for each id. Defaults to None.
- class tstore.TSWide(*args, **kwargs)[source]#
Bases:
TSWrapperAbstract wrapper for a wide-form timeseries DataFrame.
- tstore.open_tsdf(base_dir: str | Path, *args, backend: Literal['dask', 'geopandas', 'pandas', 'polars', 'pyarrow'] = 'dask', **kwargs)[source]#
Read a TStore file structure as a TSDF object.