timestamp_converter
timestamp_converter ¤
TimestampConverter ¤
TimestampConverter(
dataframe: DataFrame, column_name: str = "systime"
)
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.
convert_to_datetime
classmethod
¤
convert_to_datetime(
dataframe: DataFrame,
columns: list,
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
|
list
|
A 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. |