ts_shape.transform.time_functions.timestamp_converter
¤
Classes:
-
TimestampConverter–A class dedicated to converting high-precision timestamp data (e.g., in seconds, milliseconds, microseconds, or nanoseconds)
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.
Parameters:
-
(dataframe¤DataFrame) –The DataFrame to be processed.
-
(column_name¤str, default:'systime') –The column to sort by. Default is 'systime'. If the column is not found or is not a time column, the class will attempt to detect other time columns.
Methods:
-
convert_to_datetime–Converts specified columns from a given timestamp unit to datetime format in a target timezone.
-
get_dataframe–Returns the processed DataFrame.
Source code in src/ts_shape/utils/base.py
4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 | |
convert_to_datetime
classmethod
¤
convert_to_datetime(dataframe: DataFrame, columns: list, unit: str = 'ns', timezone: str = 'UTC') -> DataFrame
Converts specified columns from a given timestamp unit to datetime format in a target timezone.
Parameters:
-
(dataframe¤DataFrame) –The DataFrame containing the data.
-
(columns¤list) –A list of column names with timestamp data to convert.
-
(unit¤str, default:'ns') –The unit of the timestamps ('s', 'ms', 'us', or 'ns').
-
(timezone¤str, default:'UTC') –The target timezone for the converted datetime (default is 'UTC').
Returns:
-
DataFrame–pd.DataFrame: A DataFrame with the converted datetime columns in the specified timezone.
Source code in src/ts_shape/transform/time_functions/timestamp_converter.py
11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 | |
get_dataframe
¤
get_dataframe() -> DataFrame
Returns the processed DataFrame.
Source code in src/ts_shape/utils/base.py
34 35 36 | |