Class: QgsDateTimeStatisticalSummary

class qgis.core.QgsDateTimeStatisticalSummary(stats: Union[QgsDateTimeStatisticalSummary.Statistics, QgsDateTimeStatisticalSummary.Statistic] = QgsDateTimeStatisticalSummary.All)

Bases: sip.wrapper

Constructor for QgsDateTimeStatisticalSummary

Parameters:stats – flags for statistics to calculate

QgsDateTimeStatisticalSummary(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().

New in version 2.16: 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.
displayName Returns the friendly display name for a statistic
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.

Signals

Attributes

All
Count
CountDistinct
CountMissing
Max
Min
Range
All = 63
Count = 1
CountDistinct = 2
CountMissing = 4
Max = 16
Min = 8
Range = 32
class Statistic

Bases: int

class Statistics

Bases: sip.wrapper

QgsDateTimeStatisticalSummary.Statistics(Union[QgsDateTimeStatisticalSummary.Statistics, QgsDateTimeStatisticalSummary.Statistic]) QgsDateTimeStatisticalSummary.Statistics(QgsDateTimeStatisticalSummary.Statistics)

addValue(self, value: Any)

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 – 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: List[Any])

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

Parameters:values – list of variants

See also

addValue()

count(self) → int

Returns the calculated count of values.

countDistinct(self) → int

Returns the number of distinct datetime values.

countMissing(self) → int

Returns the number of missing (null) datetime values.

displayName(statistic: QgsDateTimeStatisticalSummary.Statistic) → str

Returns the friendly display name for a statistic

Parameters:statistic – statistic to return name for
distinctValues(self) → object

Returns the set of distinct datetime values.

finalize(self)

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

See also

addValue()

max(self) → QDateTime

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

min(self) → QDateTime

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

range(self) → QgsInterval

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

reset(self)

Resets the calculated values

setStatistics(self, stats: Union[QgsDateTimeStatisticalSummary.Statistics, QgsDateTimeStatisticalSummary.Statistic])

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

Parameters:stats – flags for statistics to calculate

See also

statistics()

statistic(self, stat: QgsDateTimeStatisticalSummary.Statistic) → Any

Returns the value of a specified statistic

Parameters:stat – statistic to return
Returns:calculated value of statistic
statistics(self) → QgsDateTimeStatisticalSummary.Statistics

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

See also

setStatistics()