Skip to main content
Version: 0.0.98

ts_shape.transform.time_functions.timestamp_converter

Classes
NameDescription
TimestampConverterA class dedicated to converting high-precision timestamp data (e.g., in seconds, milliseconds, microseconds, or nanoseconds)

TimestampConverter​

classsource

Bases: Base

A class dedicated to converting high-precision timestamp data (e.g., in seconds, milliseconds, microseconds, or nanoseconds) to standard datetime formats with optional timezone adjustment.

Functions
NameDescription
convert_to_datetimeConverts specified columns from a given timestamp unit to datetime format in a target timezone.

convert_to_datetime​

classmethodsource
convert_to_datetime(
dataframe: pd.DataFrame,
columns: str | list[str],
unit: str = "ns",
timezone: str = "UTC",
) -> pd.DataFrame

Converts specified columns from a given timestamp unit to datetime format in a target timezone.

Parameters
NameTypeDescriptionDefault
dataframeDataFrameThe DataFrame containing the data.required
columnsstr | listColumn name, or list of column names, with timestamp data to convert.required
unitstrThe unit of the timestamps ('s', 'ms', 'us', or 'ns').'ns'
timezonestrThe target timezone for the converted datetime (default is 'UTC').'UTC'
Returns
TypeDescription
DataFramepd.DataFrame: A DataFrame with the converted datetime columns in the specified timezone, as datetime64[ns, timezone] whatever unit is.