Skip to content

Stats Module

datachart.utils.stats

The module containing the stats methods.

The stats module provides methods for calculating statistics.

FUNCTION DESCRIPTION
count

Counts the number of elements in the list.

mean

Calculatest the mean of the values.

median

Calculates the median of the values.

stdev

Calculates the standard deviation of the values.

quantile

Calculates the quantile of the values.

minimum

Gets the minimum of the values.

maximum

Gets the maximum of the values.

Functions

datachart.utils.stats.count

count(values: List[Union[int, float]]) -> int

Counts the number of elements in a list.

Examples:

>>> from datachart.utils.stats import count
>>> count([1, 2, 3, 4, 5])
5
PARAMETER DESCRIPTION
values

The list of values.

TYPE: List[Union[int, float]]

RETURNS DESCRIPTION
int

The number of elements in the list.

datachart.utils.stats.mean

mean(values: List[Union[int, float]]) -> float

Calculates the mean of the values.

Examples:

>>> from datachart.utils.stats import mean
>>> mean([1, 2, 3, 4, 5])
3.0
PARAMETER DESCRIPTION
values

The list of values.

TYPE: List[Union[int, float]]

RETURNS DESCRIPTION
float

The mean of the values.

datachart.utils.stats.median

median(values: List[Union[int, float]]) -> float

Calculates the median of the values.

Examples:

>>> from datachart.utils.stats import median
>>> median([1, 2, 3, 4, 5])
3.0
PARAMETER DESCRIPTION
values

The list of values.

TYPE: List[Union[int, float]]

RETURNS DESCRIPTION
float

The median of the values.

datachart.utils.stats.stdev

stdev(values: List[Union[int, float]]) -> float

Calculates the standard deviation of the values.

Examples:

>>> from datachart.utils.stats import stdev
>>> stdev([1, 2, 3, 4, 5])
1.4142135623730951
PARAMETER DESCRIPTION
values

The list of values.

TYPE: List[Union[int, float]]

RETURNS DESCRIPTION
float

The standard deviation of the values.

datachart.utils.stats.quantile

quantile(
    values: List[Union[int, float]], q: float
) -> float

Calculates the quantile of the values.

Examples:

>>> from datachart.utils.stats import quantile
>>> quantile([1, 2, 3, 4, 5], 25)
2.0
PARAMETER DESCRIPTION
values

The list of values.

TYPE: List[Union[int, float]]

q

The quantile to calculate.

TYPE: float

RETURNS DESCRIPTION
float

The quantile of the values.

datachart.utils.stats.minimum

minimum(values: List[Union[int, float]]) -> float

Gets the minimum of the values.

Examples:

>>> from datachart.utils.stats import minimum
>>> minimum([1, 2, 3, 4, 5])
1
PARAMETER DESCRIPTION
values

The list of values.

TYPE: List[Union[int, float]]

RETURNS DESCRIPTION
float

The minimum of the values.

datachart.utils.stats.maximum

maximum(values: List[Union[int, float]]) -> float

Gets the maximum of the values.

Examples:

>>> from datachart.utils.stats import maximum
>>> maximum([1, 2, 3, 4, 5])
5
PARAMETER DESCRIPTION
values

The list of values.

TYPE: List[Union[int, float]]

RETURNS DESCRIPTION
float

The maximum of the values.