QgsDateTimeStatisticalSummary class
Calculator for summary statistics and aggregates for a list of datetimes.
Contents
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().
Public types
- enum Statistic { Count = 1, CountDistinct = 2, CountMissing = 4, Min = 8, Max = 16, Range = 32, All = Count | CountDistinct | CountMissing | Min | Max | Range }
- Enumeration of flags that specify statistics to be calculated.
Public static functions
-
static auto displayName(QgsDateTimeStatisticalSummary::
Statistic statistic) -> QString - Returns the friendly display name for a statistic.
Constructors, destructors, conversion operators
- QgsDateTimeStatisticalSummary(QgsDateTimeStatisticalSummary::Statistics stats = All)
- Constructor for QgsDateTimeStatisticalSummary.
Public functions
- void addValue(const QVariant& value)
- Adds a single datetime to the statistics calculation.
- void calculate(const QVariantList& values)
- Calculates summary statistics for a list of variants.
- auto count() const -> int
- Returns the calculated count of values.
- auto countDistinct() const -> int
- Returns the number of distinct datetime values.
- auto countMissing() const -> int
- Returns the number of missing (null) datetime values.
- auto distinctValues() const -> QSet<QDateTime>
- Returns the set of distinct datetime values.
- void finalize()
- Must be called after adding all datetimes with addValue() and before retrieving any calculated datetime statistics.
- auto max() const -> QDateTime
- Returns the maximum (latest) non-null datetime value.
- auto min() const -> QDateTime
- Returns the minimum (earliest) non-null datetime value.
- auto range() const -> QgsInterval
- Returns the range (interval between earliest and latest non-null datetime values).
- void reset()
- Resets the calculated values.
- void setStatistics(Statistics stats)
- Sets flags which specify which statistics will be calculated.
-
auto statistic(QgsDateTimeStatisticalSummary::
Statistic stat) const -> QVariant - Returns the value of a specified statistic.
- auto statistics() const -> Statistics
- Returns flags which specify which statistics will be calculated.
Enum documentation
enum QgsDateTimeStatisticalSummary:: Statistic
Enumeration of flags that specify statistics to be calculated.
| Enumerators | |
|---|---|
| Count |
Count. |
| CountDistinct |
Number of distinct datetime values. |
| CountMissing |
Number of missing (null) values. |
| Min |
Minimum (earliest) datetime value. |
| Max |
Maximum (latest) datetime value. |
| Range |
Interval between earliest and latest datetime value. |
| All |
Function documentation
static QString QgsDateTimeStatisticalSummary:: displayName(QgsDateTimeStatisticalSummary:: Statistic statistic)
Returns the friendly display name for a statistic.
| Parameters | |
|---|---|
| statistic | statistic to return name for |
QgsDateTimeStatisticalSummary:: QgsDateTimeStatisticalSummary(QgsDateTimeStatisticalSummary::Statistics stats = All)
Constructor for QgsDateTimeStatisticalSummary.
| Parameters | |
|---|---|
| stats | flags for statistics to calculate |
void QgsDateTimeStatisticalSummary:: addValue(const QVariant& value)
Adds a single datetime to the statistics calculation.
| Parameters | |
|---|---|
| value | datetime to add. Any non-datetime variants will be ignored. |
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().
void QgsDateTimeStatisticalSummary:: calculate(const QVariantList& values)
Calculates summary statistics for a list of variants.
| Parameters | |
|---|---|
| values | list of variants |
Any non-datetime variants will be ignored.
void QgsDateTimeStatisticalSummary:: finalize()
Must be called after adding all datetimes with addValue() and before retrieving any calculated datetime statistics.
void QgsDateTimeStatisticalSummary:: setStatistics(Statistics stats)
Sets flags which specify which statistics will be calculated.
| Parameters | |
|---|---|
| stats | flags for statistics to calculate |
Some statistics are always calculated (e.g., count).
QVariant QgsDateTimeStatisticalSummary:: statistic(QgsDateTimeStatisticalSummary:: Statistic stat) const
Returns the value of a specified statistic.
| Parameters | |
|---|---|
| stat | statistic to return |
| Returns | calculated value of statistic |
Statistics QgsDateTimeStatisticalSummary:: statistics() const
Returns flags which specify which statistics will be calculated.
Some statistics are always calculated (e.g., count).