time_stats_numeric
time_stats_numeric ¤
TimeGroupedStatistics ¤
TimeGroupedStatistics(
dataframe: DataFrame, time_column: str = "systime"
)
Bases: Base
A class for calculating time-grouped statistics on numeric data, with class methods to apply various statistical functions.
calculate_statistic
classmethod
¤
calculate_statistic(
dataframe: DataFrame,
time_column: str = "systime",
value_column: str = "value_double",
window: str = "1h",
stat_method: str = "mean",
*,
group_by_uuid: bool = True,
handle_resets: bool = True
) -> pd.DataFrame
Calculate a specified statistic on the value column over the grouped time intervals.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
dataframe
|
DataFrame
|
The DataFrame containing the data. |
required |
time_column
|
str
|
The name of the time column to group and sort by.
Default |
'systime'
|
value_column
|
str
|
The name of the numeric column to calculate statistics on.
Default |
'value_double'
|
window
|
str
|
Frequency string for time grouping (e.g., 'h' for hourly, 'D' for daily; pandas 3 rejects 'H').
Default |
'1h'
|
stat_method
|
str
|
The statistical method to apply ('mean', 'sum', 'min', 'max', 'diff', 'range').
Default |
'mean'
|
group_by_uuid
|
bool
|
When |
True
|
handle_resets
|
bool
|
For |
True
|
Returns:
| Type | Description |
|---|---|
DataFrame
|
pd.DataFrame: A DataFrame with the time intervals and the calculated statistics. |
calculate_statistics
classmethod
¤
calculate_statistics(
dataframe: DataFrame,
time_column: str = "systime",
value_column: str = "value_double",
window: str = "1h",
stat_methods: list[str] | None = None,
*,
group_by_uuid: bool = True,
handle_resets: bool = True
) -> pd.DataFrame
Calculate multiple specified statistics on the value column over the grouped time intervals.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
dataframe
|
DataFrame
|
The DataFrame containing the data. |
required |
time_column
|
str
|
The name of the time column to group and sort by.
Default |
'systime'
|
value_column
|
str
|
The name of the numeric column to calculate statistics on.
Default |
'value_double'
|
window
|
str
|
Frequency string for time grouping (e.g., 'h' for hourly, 'D' for daily; pandas 3 rejects 'H').
Default |
'1h'
|
stat_methods
|
list
|
A list of statistical methods to apply (e.g., ['mean', 'sum', 'diff', 'range']).
Default |
None
|
group_by_uuid
|
bool
|
See :meth: |
True
|
handle_resets
|
bool
|
See :meth: |
True
|
Returns:
| Type | Description |
|---|---|
DataFrame
|
pd.DataFrame: A DataFrame with the time intervals and the calculated statistics for each method. |
calculate_custom_func
classmethod
¤
calculate_custom_func(
dataframe: DataFrame,
time_column: str = "systime",
value_column: str = "value_double",
window: str = "1h",
func: Callable[[Series], Any] | None = None,
*,
group_by_uuid: bool = True
) -> pd.DataFrame
Apply a custom aggregation function on the value column over the grouped time intervals.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
dataframe
|
DataFrame
|
The DataFrame containing the data. |
required |
time_column
|
str
|
The name of the time column to group and sort by.
Default |
'systime'
|
value_column
|
str
|
The name of the numeric column to calculate statistics on.
Default |
'value_double'
|
window
|
str
|
Frequency string for time grouping (e.g., 'h' for hourly, 'D' for daily; pandas 3 rejects 'H').
Default |
'1h'
|
func
|
callable
|
Custom function to apply to each group (required). |
None
|
group_by_uuid
|
bool
|
See :meth: |
True
|
Returns:
| Type | Description |
|---|---|
DataFrame
|
pd.DataFrame: A DataFrame with the custom calculated statistics in
the column |