ts_shape.features.cycles.cycle_processor
¤
Classes:
-
CycleDataProcessor
–A class to process cycle-based data and values. It allows for splitting, merging, and grouping DataFrames
CycleDataProcessor
¤
CycleDataProcessor(cycles_df: DataFrame, values_df: DataFrame, cycle_uuid_col: str = 'cycle_uuid', systime_col: str = 'systime')
Bases: Base
A class to process cycle-based data and values. It allows for splitting, merging, and grouping DataFrames based on cycles, as well as handling grouping and transformations by cycle UUIDs.
Parameters:
-
cycles_df
¤DataFrame
) –DataFrame containing columns 'cycle_start', 'cycle_end', and 'cycle_uuid'.
-
values_df
¤DataFrame
) –DataFrame containing the values and timestamps in the 'systime' column.
-
cycle_uuid_col
¤str
, default:'cycle_uuid'
) –Name of the column representing cycle UUIDs.
-
systime_col
¤str
, default:'systime'
) –Name of the column representing the timestamps for the values.
Methods:
-
get_dataframe
–Returns the processed DataFrame.
-
group_by_cycle_uuid
–Group the DataFrame by the cycle_uuid column, resulting in a list of DataFrames, each containing data for one cycle.
-
merge_dataframes_by_cycle
–Merges the values DataFrame with the cycles DataFrame based on the cycle time intervals.
-
split_by_cycle
–Splits the values DataFrame by cycles defined in the cycles DataFrame.
-
split_dataframes_by_group
–Splits a list of DataFrames by groups based on a specified column.
Source code in src/ts_shape/features/cycles/cycle_processor.py
13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 |
|
get_dataframe
¤
get_dataframe() -> DataFrame
Returns the processed DataFrame.
Source code in src/ts_shape/utils/base.py
34 35 36 |
|
group_by_cycle_uuid
¤
Group the DataFrame by the cycle_uuid column, resulting in a list of DataFrames, each containing data for one cycle.
Parameters:
-
data
¤Optional[DataFrame]
, default:None
) –DataFrame containing the data to be grouped by cycle_uuid. If None, uses the internal values_df.
Return
List of DataFrames, each containing data for a unique cycle_uuid.
Source code in src/ts_shape/features/cycles/cycle_processor.py
71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 |
|
merge_dataframes_by_cycle
¤
merge_dataframes_by_cycle() -> DataFrame
Merges the values DataFrame with the cycles DataFrame based on the cycle time intervals. Appends the 'cycle_uuid' to the values DataFrame.
Return
DataFrame with an added 'cycle_uuid' column.
Source code in src/ts_shape/features/cycles/cycle_processor.py
52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 |
|
split_by_cycle
¤
Splits the values DataFrame by cycles defined in the cycles DataFrame. Each cycle is defined by a start and end time, and the corresponding values are filtered accordingly.
Return
Dictionary where keys are cycle_uuids and values are DataFrames with the corresponding cycle data.
Source code in src/ts_shape/features/cycles/cycle_processor.py
36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 |
|
split_dataframes_by_group
¤
Splits a list of DataFrames by groups based on a specified column. This function performs a groupby operation on each DataFrame in the list and then flattens the result.
Parameters:
Return
List of DataFrames, each corresponding to a group in the original DataFrames.
Source code in src/ts_shape/features/cycles/cycle_processor.py
88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 |
|