caikit.interfaces.ts.data_model._single_timeseries ================================================== .. py:module:: caikit.interfaces.ts.data_model._single_timeseries .. autoapi-nested-parse:: The core data model object for a TimeSeries Attributes ---------- .. autoapisummary:: caikit.interfaces.ts.data_model._single_timeseries.log caikit.interfaces.ts.data_model._single_timeseries.error Classes ------- .. autoapisummary:: caikit.interfaces.ts.data_model._single_timeseries.SingleTimeSeries Module Contents --------------- .. py:data:: log .. py:data:: error .. py:class:: SingleTimeSeries(*args, **kwargs) Bases: :py:obj:`caikit.core.DataObjectBase` The TimeSeries object is the central data container for the library. At present it wraps either a pandas.DataFrame, or pyspark.sql.DataFrame to bind into the caikit data model. .. py:class:: StringIDSequence Bases: :py:obj:`caikit.core.DataObjectBase` Nested value sequence of strings .. py:attribute:: values :type: py_to_proto.dataclass_to_proto.Annotated[List[str], FieldNumber(1)] .. py:class:: IntIDSequence Bases: :py:obj:`caikit.core.DataObjectBase` Nested value sequence of ints .. py:attribute:: values :type: py_to_proto.dataclass_to_proto.Annotated[List[int], FieldNumber(1)] .. py:attribute:: time_sequence :type: Union[py_to_proto.dataclass_to_proto.Annotated[caikit.interfaces.ts.data_model.time_types.PeriodicTimeSequence, OneofField('time_period'), FieldNumber(10)], py_to_proto.dataclass_to_proto.Annotated[caikit.interfaces.ts.data_model.time_types.PointTimeSequence, OneofField('time_points'), FieldNumber(20)]] .. py:attribute:: values :type: py_to_proto.dataclass_to_proto.Annotated[List[caikit.interfaces.ts.data_model.time_types.ValueSequence], FieldNumber(1)] .. py:attribute:: timestamp_label :type: py_to_proto.dataclass_to_proto.Annotated[str, FieldNumber(2)] .. py:attribute:: value_labels :type: py_to_proto.dataclass_to_proto.Annotated[List[str], FieldNumber(3)] .. py:attribute:: ids :type: Union[py_to_proto.dataclass_to_proto.Annotated[SingleTimeSeries.IntIDSequence, OneofField('id_int'), FieldNumber(30)], py_to_proto.dataclass_to_proto.Annotated[SingleTimeSeries.StringIDSequence, OneofField('id_str'), FieldNumber(40)]] .. py:attribute:: _DEFAULT_TS_COL :value: 'timestamp' .. py:method:: _get_pd_df() -> Tuple[pandas.DataFrame, str, Iterable[str]] Convert the data to a pandas DataFrame, efficiently if possible .. py:method:: __len__() -> int Return the length of the single time series object. Returns: int: Length .. py:method:: __eq__(other: SingleTimeSeries) -> bool Equivalence operator for SingleTimeSeries objects. Performs ordering of data based on timestamp_label prior to checking for equivalence. Relies on underlying pandas equivalence testing function `pd.testing.assert_frame_equal`. Args: other (SingleTimeSeries): SingleTimeSeries to test against. Returns: bool: True if the SingleTimeSeries are equivalent. .. py:method:: _as_pandas_ops(adf, include_timestamps: Union[None, bool] = False) operate on pandas-like object instead of strictly pandas .. py:method:: as_pandas(include_timestamps: Optional[bool] = None) -> pandas.DataFrame Get the view of this timeseries as a pandas DataFrame Args: include_timestamps (bool, optional): Control the addition or removal of timestamps. True will include timestamps, generating if needed, while False will remove timestamps. Use None to returned what is available, leaving unchanged. Defaults to None. Returns: pd.DataFrame: The view of the data as a pandas DataFrame .. py:method:: as_spark(include_timestamps: Optional[bool] = None) -> caikit.interfaces.ts.data_model.toolkit.optional_dependencies.pyspark.sql.DataFrame Get the view of this timeseries as a spark DataFrame Args: include_timestamps (bool, optional): Control the addition or removal of timestamps. True will include timestamps, generating if needed, while False will remove timestamps. Use None to returned what is available, leaving unchanged. Defaults to None. Returns: pyspark.sql.DataFrame: The view of the data as a spark DataFrame