ts_shape.transform.time_functions.timestamp_converter
Classes
| Name | Description |
|---|---|
TimestampConverter | A class dedicated to converting high-precision timestamp data (e.g., in seconds, milliseconds, microseconds, or nanoseconds) |
TimestampConverter
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
| Name | Description |
|---|---|
convert_to_datetime | Converts specified columns from a given timestamp unit to datetime format in a target timezone. |
convert_to_datetime
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
| Name | Type | Description | Default |
|---|---|---|---|
dataframe | DataFrame | The DataFrame containing the data. | required |
columns | str | list | Column name, or list of column names, with timestamp data to convert. | required |
unit | str | The unit of the timestamps ('s', 'ms', 'us', or 'ns'). | 'ns' |
timezone | str | The target timezone for the converted datetime (default is 'UTC'). | 'UTC' |
Returns
| Type | Description |
|---|---|
DataFrame | pd.DataFrame: A DataFrame with the converted datetime columns in the specified timezone, as datetime64[ns, timezone] whatever unit is. |