pandas_ts.ts_ext_array
Module Contents
Classes
Pandas extension array for TS structure array |
- class TsExtensionArray(values: pyarrow.Array | pyarrow.ChunkedArray, *, validate: bool = True)[source]
Bases:
pandas.core.arrays.ArrowExtensionArrayPandas extension array for TS structure array
- Parameters:
values (pyarrow.Array or pyarrow.ChunkedArray) – The array to be wrapped, must be a struct array with all fields being list arrays of the same lengths.
validate (bool, default True) – Whether to validate the input array.
- Raises:
ValueError – If the input array is not a struct array or if any of the fields is not a list array or if the list arrays have different lengths.
- property list_offsets: pyarrow.ChunkedArray[source]
The list offsets of the field arrays.
It is a chunk array of list offsets of the first field array. (Since all fields are validated to have the same offsets.)
- Returns:
The list offsets of the field arrays.
- Return type:
pa.ChunkedArray
- static _convert_df_to_pa_scalar(df: pandas.DataFrame, *, type: pyarrow.DataType | None) pyarrow.Scalar[source]
- classmethod _from_sequence(scalars, *, dtype=None, copy: bool = False) Self[source]
Construct a new ExtensionArray from a sequence of scalars.
- __getitem__(item)[source]
Select a subset of self.
- Parameters:
item (int, slice, or ndarray) –
int: The position in ‘self’ to get.
slice: A slice object, where ‘start’, ‘stop’, and ‘step’ are integers or None
ndarray: A 1-d boolean NumPy ndarray the same length as ‘self’
- Returns:
item
- Return type:
scalar or ExtensionArray
Notes
For scalar
item, return a scalar value suitable for the array’s type. This should be an instance ofself.dtype.type. For slicekey, return an instance ofExtensionArray, even if the slice is length 0 or 1. For a boolean mask, return an instance ofExtensionArray, filtered to the values whereitemis True.
- to_numpy(dtype: None = None, copy: bool = False, na_value: Any = no_default) numpy.ndarray[source]
Convert the extension array to a numpy array.
- Parameters:
dtype (None) – This parameter is left for compatibility with the base class method, but it is not used. dtype of the returned array is always object.
copy (bool, default False) – Whether to copy the data. It is not garanteed that the data will not be copied if copy is False.
na_value (Any, default no_default) – TODO: support NA values
- Returns:
The numpy array of pd.DataFrame objects. Each element is a single time-series.
- Return type:
np.ndarray
- __setitem__(key, value) None[source]
Set one or more values inplace.
- Parameters:
key (int, ndarray, or slice) –
When called from, e.g.
Series.__setitem__,keywill be one ofscalar int
ndarray of integers.
boolean ndarray
slice object
value (ExtensionDtype.type, Sequence[ExtensionDtype.type], or object) – value or values to be set of
key.
- Return type:
None
- view_fields(fields: str | list[str]) Self[source]
Get a view of the series with only the specified fields
- Parameters:
fields (str or list of str) – The name of the field or a list of names of the fields to include.
- Returns:
The view of the series with only the specified fields.
- Return type:
- set_flat_field(field: str, value: numpy.typing.ArrayLike) None[source]
Set the field from flat-array of values
- Parameters:
field (str) – The name of the field.
value (ArrayLike) – The ‘flat’ array of values to be set.