Class: QgsDateTimeStatisticalSummary

Calculator for summary statistics and aggregates for a list of datetimes.

Statistics are calculated by calling calculate() and passing a list of datetimes. The individual statistics can then be retrieved using the associated methods. Note that not all statistics are calculated by default. Statistics which require slower computations are only calculated by specifying the statistic in the constructor or via setStatistics().

Enums

Statistic

alias of DateTimeStatistic

Methods

addValue

Adds a single datetime to the statistics calculation.

calculate

Calculates summary statistics for a list of variants.

count

Returns the calculated count of values.

countDistinct

Returns the number of distinct datetime values.

countMissing

Returns the number of missing (null) datetime values.

distinctValues

Returns the set of distinct datetime values.

finalize

Must be called after adding all datetimes with addValue() and before retrieving any calculated datetime statistics.

max

Returns the maximum (latest) non-null datetime value.

min

Returns the minimum (earliest) non-null datetime value.

range

Returns the range (interval between earliest and latest non-null datetime values).

reset

Resets the calculated values

setStatistics

Sets flags which specify which statistics will be calculated.

statistic

Returns the value of a specified statistic

statistics

Returns flags which specify which statistics will be calculated.

Static Methods

displayName

Returns the friendly display name for a statistic

class qgis.core.QgsDateTimeStatisticalSummary[source]

Bases: object

__init__(stats: Qgis.DateTimeStatistics | Qgis.DateTimeStatistic = Qgis.DateTimeStatistic.All)

Constructor for QgsDateTimeStatisticalSummary

Parameters:

stats (Union[Qgis.DateTimeStatistics, Qgis.DateTimeStatistic] = Qgis.DateTimeStatistic.All) – flags for statistics to calculate

__init__(a0: QgsDateTimeStatisticalSummary)
Parameters:

a0 (QgsDateTimeStatisticalSummary)

Statistic

alias of DateTimeStatistic

Statistics

alias of DateTimeStatistics

addValue(self, value: Any)[source]

Adds a single datetime to the statistics calculation. Calling this method allows datetimes to be added to the calculation one at a time. For large quantities of dates this may be more efficient then first adding all the variants to a list and calling calculate().

Parameters:

value (Any) – datetime to add. Any non-datetime variants will be ignored.

Note

call reset() before adding the first datetime using this method to clear the results from any previous calculations

Note

finalize() must be called after adding the final value and before retrieving calculated statistics.

See also

calculate()

See also

finalize()

calculate(self, values: Iterable[Any])[source]

Calculates summary statistics for a list of variants. Any non-datetime variants will be ignored.

Parameters:

values (Iterable[Any]) – list of variants

See also

addValue()

count(self) int[source]

Returns the calculated count of values.

Return type:

int

countDistinct(self) int[source]

Returns the number of distinct datetime values.

Return type:

int

countMissing(self) int[source]

Returns the number of missing (null) datetime values.

Return type:

int

static displayName(statistic: Qgis.DateTimeStatistic) str[source]

Returns the friendly display name for a statistic

Parameters:

statistic (Qgis.DateTimeStatistic) – statistic to return name for

Return type:

str

distinctValues(self) Set[QDateTime]

Returns the set of distinct datetime values.

Return type:

Set[QDateTime]

finalize(self)[source]

Must be called after adding all datetimes with addValue() and before retrieving any calculated datetime statistics.

See also

addValue()

max(self) QDateTime[source]

Returns the maximum (latest) non-null datetime value.

Return type:

QDateTime

min(self) QDateTime[source]

Returns the minimum (earliest) non-null datetime value.

Return type:

QDateTime

range(self) QgsInterval[source]

Returns the range (interval between earliest and latest non-null datetime values).

Return type:

QgsInterval

reset(self)[source]

Resets the calculated values

setStatistics(self, stats: Qgis.DateTimeStatistics | Qgis.DateTimeStatistic)[source]

Sets flags which specify which statistics will be calculated. Some statistics are always calculated (e.g., count).

Parameters:

stats (Union[Qgis.DateTimeStatistics, Qgis.DateTimeStatistic]) – flags for statistics to calculate

See also

statistics()

statistic(self, stat: Qgis.DateTimeStatistic) Any[source]

Returns the value of a specified statistic

Parameters:

stat (Qgis.DateTimeStatistic) – statistic to return

Return type:

Any

Returns:

calculated value of statistic

statistics(self) Qgis.DateTimeStatistics[source]

Returns flags which specify which statistics will be calculated. Some statistics are always calculated (e.g., count).

See also

setStatistics()

Return type:

Qgis.DateTimeStatistics