pandas_ts.ts_accessor
Module Contents
Classes
Accessor for operations on Series of TsDtype |
- class TsAccessor(series)[source]
Bases:
collections.abc.MutableMappingAccessor for operations on Series of TsDtype
This accessor implements MutableMapping interface over the fields of the struct, so you can access, change and delete the fields as if it was a dictionary, with [], [] = and del operators.
- to_lists(fields: list[str] | None = None) pandas.DataFrame[source]
Convert ts into dataframe of list-array columns
- Parameters:
fields (list[str] or None, optional) – Names of the fields to include. Default is None, which means all fields.
- Returns:
Dataframe of list-arrays.
- Return type:
pd.DataFrame
- to_flat(fields: list[str] | None = None) pandas.DataFrame[source]
Convert ts into dataframe of flat arrays
- Parameters:
fields (list[str] or None, optional) – Names of the fields to include. Default is None, which means all fields.
- Returns:
Dataframe of flat arrays.
- Return type:
pd.DataFrame
- set_flat_field(field: str, value: numpy.typing.ArrayLike) None[source]
Set the field from flat-array of values, in-place
- Parameters:
field (str) – Name of the field to set. If not present, it will be added.
value (ArrayLike) –
- Array of values to set. It must be a scalar or have the same length
as the flat arrays, e.g. self.flat_length.
- set_list_field(field: str, value: numpy.typing.ArrayLike) None[source]
Set the field from list-array, in-place
- Parameters:
field (str) – Name of the field to set. If not present, it will be added.
value (ArrayLike) –
- Array of values to set. It must be a list-array of the same length
as the series, e.g. length of the series.
- pop_field(field: str) pandas.Series[source]
Delete the field from the struct and return it.
- Parameters:
field (str) – Name of the field to delete.
- Returns:
The deleted field.
- Return type:
pd.Series
- query_flat(query: str) pandas.Series[source]
Query the flat arrays with a boolean expression
Currently, it will remove empty rows from the output series. # TODO: preserve the index keeping empty rows
- Parameters:
query (str) – Boolean expression to filter the rows.
- Returns:
The filtered series.
- Return type:
pd.Series