tstore.tsdf package#

Submodules#

tstore.tsdf.geopandas module#

TSDF class wrapping a GeoPandas dataframe of TSArray objects.

class tstore.tsdf.geopandas.TSDFGeoPandas(*args, **kwargs)[source]#

Bases: TSDF

Wrapper for a GeoPandas DataFrame of TSArray objects.

tstore.tsdf.pandas module#

TSDF class wrapping a Pandas dataframe of TSArray objects.

class tstore.tsdf.pandas.TSDFPandas(*args, **kwargs)[source]#

Bases: TSDF

Wrapper for a Pandas DataFrame of TSArray objects.

tstore.tsdf.reader module#

Created on Mon Jun 12 15:48:39 2023.

@author: ghiggi

tstore.tsdf.ts_class module#

Created on Mon Jun 12 22:17:59 2023.

@author: ghiggi

class tstore.tsdf.ts_class.TS(df: DataFrame | GeoDataFrame | DataFrame | DataFrame | Table, time_var='time')[source]#

Bases: object

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

to_disk(fpath, partitioning_str=None)[source]#

Write TS object to disk.

tstore.tsdf.ts_class.check_time_index(df)[source]#

Check pandas/dask index is datetime.

tstore.tsdf.ts_class.ensure_is_dask_dataframe(data)[source]#

Convert a table to a dask dataframe.

tstore.tsdf.ts_dtype module#

Created on Mon Jun 12 16:23:54 2023.

@author: ghiggi

class tstore.tsdf.ts_dtype.TSDtype(ts_class=None)[source]#

Bases: ExtensionDtype

An ExtensionDtype for TS time series data.

classmethod construct_array_type()[source]#

Return the array type associated with this dtype.

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.

type#

alias of TS

tstore.tsdf.tsarray module#

Created on Sun Jun 11 22:47:54 2023.

@author: ghiggi

class tstore.tsdf.tsarray.TSArray(data, copy: bool = False)[source]#

Bases: ExtensionArray

An ExtensionArray for TS objects, holding the array-based implementations.

copy()[source]#

Return a copy of the array.

property dtype#

An instance of TSDtype.

isna()[source]#

A 1-D array indicating if the TS is missing.

property nbytes: int#

The number of bytes needed to store this object in memory.

take(indices, allow_fill=False, fill_value=None)[source]#

Take elements from an array.

property ts_class#

TS inner class.

tstore.tsdf.tsarray.get_tabular_object_type(obj)[source]#

Get inner class of the TS object.

tstore.tsdf.tsdf module#

Module defining the TSDF abstract wrapper for a dataframe of TSArray objects.

class tstore.tsdf.tsdf.TSDF(*args, **kwargs)[source]#

Bases: TSWrapper

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

to_tswide(backend: Literal['dask', 'geopandas', 'pandas', 'polars', 'pyarrow'] = 'dask') TSWide[source]#

Convert the wrapper into a TSWide object.

static wrap(self, df: DataFrame | GeoDataFrame | DataFrame | DataFrame | Table, id_var: str) TSDF[source]#

Wrap a DataFrame of TSArrays as a TSDF object.

Parameters:
  • df (pd.DataFrame) – DataFrame to wrap.

  • id_var (str) – Name of the column containing the identifier variable.

tstore.tsdf.tsdf.get_ts_columns(df: DataFrame) list[str][source]#

Return the list of columns containing TS objects.

tstore.tsdf.writer module#

Created on Mon Jun 12 15:49:54 2023.

@author: ghiggi

tstore.tsdf.writer.write_tstore(df, base_dir, id_var, partitioning, tstore_structure='id-var', overwrite=True)[source]#

Write TStore from TSDF object.

Module contents#

TSDF package.

class tstore.tsdf.TSDF(*args, **kwargs)[source]#

Bases: TSWrapper

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

to_tswide(backend: Literal['dask', 'geopandas', 'pandas', 'polars', 'pyarrow'] = 'dask') TSWide[source]#

Convert the wrapper into a TSWide object.

static wrap(self, df: DataFrame | GeoDataFrame | DataFrame | DataFrame | Table, id_var: str) TSDF[source]#

Wrap a DataFrame of TSArrays as a TSDF object.

Parameters:
  • df (pd.DataFrame) – DataFrame to wrap.

  • id_var (str) – Name of the column containing the identifier variable.

tstore.tsdf.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.