Skip to content

time_stats_numeric

time_stats_numeric ¤

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.

calculate_statistic classmethod ¤

calculate_statistic(
    dataframe: DataFrame,
    time_column: str,
    value_column: str,
    freq: str,
    stat_method: str,
) -> 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.

required
value_column str

The name of the numeric column to calculate statistics on.

required
freq str

Frequency string for time grouping (e.g., 'H' for hourly, 'D' for daily).

required
stat_method str

The statistical method to apply ('mean', 'sum', 'min', 'max', 'diff', 'range').

required

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,
    value_column: str,
    freq: str,
    stat_methods: list,
) -> 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.

required
value_column str

The name of the numeric column to calculate statistics on.

required
freq str

Frequency string for time grouping (e.g., 'H' for hourly, 'D' for daily).

required
stat_methods list

A list of statistical methods to apply (e.g., ['mean', 'sum', 'diff', 'range']).

required

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,
    value_column: str,
    freq: str,
    func,
) -> 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.

required
value_column str

The name of the numeric column to calculate statistics on.

required
freq str

Frequency string for time grouping (e.g., 'H' for hourly, 'D' for daily).

required
func callable

Custom function to apply to each group.

required

Returns:

Type Description
DataFrame

pd.DataFrame: A DataFrame with the custom calculated statistics.