Skip to main content
Version: Next

ts_shape.features.stats.numeric_stats

Classes
NameDescription
NumericStatisticsProvides class methods to calculate statistics on numeric columns in a pandas DataFrame.

NumericStatistics​

classsource

Bases: Base

Provides class methods to calculate statistics on numeric columns in a pandas DataFrame.

Functions
NameDescription
column_meanCalculate the mean of a specified column.
column_medianCalculate the median of a specified column.
column_stdCalculate the standard deviation of a specified column.
column_varianceCalculate the variance of a specified column.
column_minCalculate the minimum value of a specified column.
column_maxCalculate the maximum value of a specified column.
column_sumCalculate the sum of a specified column.
column_kurtosisCalculate the kurtosis of a specified column.
column_skewnessCalculate the skewness of a specified column.
column_quantileCalculate a specific quantile of the column.
column_iqrCalculate the interquartile range of the column.
column_rangeCalculate the range of the column.
column_madCalculate the mean absolute deviation of the column.
column_modeCalculate the mode of a specified column. Returns None if column is empty.
coefficient_of_variationCalculate the coefficient of variation of the column.
standard_error_meanCalculate the standard error of the mean for the column.
describeProvide a statistical summary for numeric columns in the DataFrame.
summary_as_dictReturns a dictionary with comprehensive numeric statistics for the specified column.
summary_as_dataframeReturns a DataFrame with comprehensive numeric statistics for the specified column.

column_mean​

classmethodsource
column_mean(dataframe: pd.DataFrame, value_column: str) -> float

Calculate the mean of a specified column.

Parameters
NameTypeDescriptionDefault
dataframeDataFrameInput DataFrame.required
value_columnstrName of the numeric column to analyze.required
Returns
TypeDescription
floatThe mean of the non-missing values; NaN when there is none.

column_median​

classmethodsource
column_median(dataframe: pd.DataFrame, value_column: str) -> float

Calculate the median of a specified column.

Parameters
NameTypeDescriptionDefault
dataframeDataFrameInput DataFrame.required
value_columnstrName of the numeric column to analyze.required
Returns
TypeDescription
floatThe median of the non-missing values; NaN when there is none.

column_std​

classmethodsource
column_std(dataframe: pd.DataFrame, value_column: str) -> float

Calculate the standard deviation of a specified column.

Parameters
NameTypeDescriptionDefault
dataframeDataFrameInput DataFrame.required
value_columnstrName of the numeric column to analyze.required
Returns
TypeDescription
floatThe sample standard deviation (ddof=1); NaN for fewer than 2 values.

column_variance​

classmethodsource
column_variance(dataframe: pd.DataFrame, value_column: str) -> float

Calculate the variance of a specified column.

Parameters
NameTypeDescriptionDefault
dataframeDataFrameInput DataFrame.required
value_columnstrName of the numeric column to analyze.required
Returns
TypeDescription
floatThe sample variance (ddof=1); NaN for fewer than 2 values.

column_min​

classmethodsource
column_min(dataframe: pd.DataFrame, value_column: str) -> float

Calculate the minimum value of a specified column.

Parameters
NameTypeDescriptionDefault
dataframeDataFrameInput DataFrame.required
value_columnstrName of the numeric column to analyze.required
Returns
TypeDescription
floatThe smallest value; NaN when there is none.

column_max​

classmethodsource
column_max(dataframe: pd.DataFrame, value_column: str) -> float

Calculate the maximum value of a specified column.

Parameters
NameTypeDescriptionDefault
dataframeDataFrameInput DataFrame.required
value_columnstrName of the numeric column to analyze.required
Returns
TypeDescription
floatThe largest value; NaN when there is none.

column_sum​

classmethodsource
column_sum(dataframe: pd.DataFrame, value_column: str) -> float

Calculate the sum of a specified column.

Parameters
NameTypeDescriptionDefault
dataframeDataFrameInput DataFrame.required
value_columnstrName of the numeric column to analyze.required
Returns
TypeDescription
floatThe sum of the values; 0 when there is none. An integer column is summed exactly: in int64 when the sum cannot overflow (a numpy integer is returned, as before), otherwise with Python integers (a Python int), so a sum beyond the int64 range is not wrapped around. float64 is not used for this: it is exact only up to 2**53.

column_kurtosis​

classmethodsource
column_kurtosis(dataframe: pd.DataFrame, value_column: str) -> float

Calculate the kurtosis of a specified column.

Parameters
NameTypeDescriptionDefault
dataframeDataFrameInput DataFrame.required
value_columnstrName of the numeric column to analyze.required
Returns
TypeDescription
floatThe bias-corrected excess kurtosis; NaN for fewer than 4 values.

column_skewness​

classmethodsource
column_skewness(dataframe: pd.DataFrame, value_column: str) -> float

Calculate the skewness of a specified column.

Parameters
NameTypeDescriptionDefault
dataframeDataFrameInput DataFrame.required
value_columnstrName of the numeric column to analyze.required
Returns
TypeDescription
floatThe bias-corrected skewness; NaN for fewer than 3 values.

column_quantile​

classmethodsource
column_quantile(
dataframe: pd.DataFrame, value_column: str, quantile: float
) -> float

Calculate a specific quantile of the column.

Parameters
NameTypeDescriptionDefault
dataframeDataFrameInput DataFrame.required
value_columnstrName of the numeric column to analyze.required
quantilefloatQuantile to compute, between 0 and 1 (0.5 is the median).required
Returns
TypeDescription
floatThe quantile (linear interpolation); NaN when there is no value.

column_iqr​

classmethodsource
column_iqr(dataframe: pd.DataFrame, value_column: str) -> float

Calculate the interquartile range of the column.

Parameters
NameTypeDescriptionDefault
dataframeDataFrameInput DataFrame.required
value_columnstrName of the numeric column to analyze.required
Returns
TypeDescription
floatThird minus first quartile of the non-missing values; NaN when there is none.

column_range​

classmethodsource
column_range(dataframe: pd.DataFrame, value_column: str) -> float

Calculate the range of the column.

Parameters
NameTypeDescriptionDefault
dataframeDataFrameInput DataFrame.required
value_columnstrName of the numeric column to analyze.required
Returns
TypeDescription
floatLargest minus smallest value; NaN when there is none. For an integer column the difference is taken with Python integers, so it is exact and does not wrap around: an int64 result when it fits, else a Python int (e.g. 2**63 + 1 for [2**62 + 1, -2**62]).

column_mad​

classmethodsource
column_mad(dataframe: pd.DataFrame, value_column: str) -> float

Calculate the mean absolute deviation of the column.

Parameters
NameTypeDescriptionDefault
dataframeDataFrameInput DataFrame.required
value_columnstrName of the numeric column to analyze.required
Returns
TypeDescription
floatThe mean absolute deviation from the mean; NaN when there is no value.

column_mode​

classmethodsource
column_mode(dataframe: pd.DataFrame, value_column: str) -> float | None

Calculate the mode of a specified column. Returns None if column is empty.

Parameters
NameTypeDescriptionDefault
dataframeDataFrameInput DataFrame.required
value_columnstrName of the numeric column to analyze.required
Returns
TypeDescription
float | NoneThe most frequent value (the smallest on a tie), or None when there is no value.

coefficient_of_variation​

classmethodsource
coefficient_of_variation(dataframe: pd.DataFrame, value_column: str) -> float

Calculate the coefficient of variation of the column.

Parameters
NameTypeDescriptionDefault
dataframeDataFrameInput DataFrame.required
value_columnstrName of the numeric column to analyze.required
Returns
TypeDescription
floatStandard deviation divided by the mean, or float("nan") when the
floatmean is 0 (the ratio is undefined).

standard_error_mean​

classmethodsource
standard_error_mean(dataframe: pd.DataFrame, value_column: str) -> float

Calculate the standard error of the mean for the column.

Parameters
NameTypeDescriptionDefault
dataframeDataFrameInput DataFrame.required
value_columnstrName of the numeric column to analyze.required
Returns
TypeDescription
floatThe standard error of the mean; NaN for fewer than 2 values.

describe​

classmethodsource
describe(dataframe: pd.DataFrame) -> pd.DataFrame

Provide a statistical summary for numeric columns in the DataFrame.

Parameters
NameTypeDescriptionDefault
dataframeDataFrameInput DataFrame; every numeric column is described.required
Returns
TypeDescription
DataFrameThe output of DataFrame.describe(): one column per numeric column, rows count, mean, std, min, 25%, 50%, 75% and max.

summary_as_dict​

classmethodsource
summary_as_dict(
dataframe: pd.DataFrame, value_column: str
) -> dict[str, float | int | None]

Returns a dictionary with comprehensive numeric statistics for the specified column.

Parameters
NameTypeDescriptionDefault
dataframeDataFrameInput DataFrame.required
value_columnstrName of the numeric column to analyze.required
Returns
TypeDescription
dict[str, float | int | None]Dict with keys min, max, mean, median, std, var, sum, kurtosis, skewness, q1, q3, iqr, range, mad, coeff_var, sem, mode, percentile_90 and percentile_10.

summary_as_dataframe​

classmethodsource
summary_as_dataframe(
dataframe: pd.DataFrame, value_column: str
) -> pd.DataFrame

Returns a DataFrame with comprehensive numeric statistics for the specified column.

Parameters
NameTypeDescriptionDefault
dataframeDataFrameInput DataFrame.required
value_columnstrName of the numeric column to analyze.required
Returns
TypeDescription
DataFrameOne-row DataFrame with the keys of summary_as_dict as columns.