ts_shape.features.time_stats.time_stats_numeric
¤
Classes:
-
TimeGroupedStatistics
–A class for calculating time-grouped statistics on numeric data, with class methods to apply various statistical functions.
TimeGroupedStatistics
¤
TimeGroupedStatistics(dataframe: DataFrame, column_name: str = 'systime')
Bases: Base
A class for calculating time-grouped statistics on numeric data, with class methods to apply various statistical functions.
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:
-
calculate_custom_func
–Apply a custom aggregation function on the value column over the grouped time intervals.
-
calculate_statistic
–Calculate a specified statistic on the value column over the grouped time intervals.
-
calculate_statistics
–Calculate multiple specified statistics on the value column over the grouped time intervals.
-
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 |
|
calculate_custom_func
classmethod
¤
calculate_custom_func(dataframe: DataFrame, time_column: str, value_column: str, freq: str, func) -> DataFrame
Apply a custom aggregation function on the value column over the grouped time intervals.
Parameters:
-
dataframe
¤DataFrame
) –The DataFrame containing the data.
-
time_column
¤str
) –The name of the time column to group and sort by.
-
value_column
¤str
) –The name of the numeric column to calculate statistics on.
-
freq
¤str
) –Frequency string for time grouping (e.g., 'H' for hourly, 'D' for daily).
-
func
¤callable
) –Custom function to apply to each group.
Returns:
-
DataFrame
–pd.DataFrame: A DataFrame with the custom calculated statistics.
Source code in src/ts_shape/features/time_stats/time_stats_numeric.py
72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 |
|
calculate_statistic
classmethod
¤
calculate_statistic(dataframe: DataFrame, time_column: str, value_column: str, freq: str, stat_method: str) -> DataFrame
Calculate a specified statistic on the value column over the grouped time intervals.
Parameters:
-
dataframe
¤DataFrame
) –The DataFrame containing the data.
-
time_column
¤str
) –The name of the time column to group and sort by.
-
value_column
¤str
) –The name of the numeric column to calculate statistics on.
-
freq
¤str
) –Frequency string for time grouping (e.g., 'H' for hourly, 'D' for daily).
-
stat_method
¤str
) –The statistical method to apply ('mean', 'sum', 'min', 'max', 'diff', 'range').
Returns:
-
DataFrame
–pd.DataFrame: A DataFrame with the time intervals and the calculated statistics.
Source code in src/ts_shape/features/time_stats/time_stats_numeric.py
9 10 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 42 43 44 45 |
|
calculate_statistics
classmethod
¤
calculate_statistics(dataframe: DataFrame, time_column: str, value_column: str, freq: str, stat_methods: list) -> DataFrame
Calculate multiple specified statistics on the value column over the grouped time intervals.
Parameters:
-
dataframe
¤DataFrame
) –The DataFrame containing the data.
-
time_column
¤str
) –The name of the time column to group and sort by.
-
value_column
¤str
) –The name of the numeric column to calculate statistics on.
-
freq
¤str
) –Frequency string for time grouping (e.g., 'H' for hourly, 'D' for daily).
-
stat_methods
¤list
) –A list of statistical methods to apply (e.g., ['mean', 'sum', 'diff', 'range']).
Returns:
-
DataFrame
–pd.DataFrame: A DataFrame with the time intervals and the calculated statistics for each method.
Source code in src/ts_shape/features/time_stats/time_stats_numeric.py
47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 |
|
get_dataframe
¤
get_dataframe() -> DataFrame
Returns the processed DataFrame.
Source code in src/ts_shape/utils/base.py
34 35 36 |
|