Aggregate Time Series Values Cardinality

async AsyncCogniteClient.time_series.aggregate_cardinality_values(
property: TimeSeriesProperty | str | list[str],
advanced_filter: Filter | dict[str, Any] | None = None,
aggregate_filter: AggregationFilter | dict[str, Any] | None = None,
filter: TimeSeriesFilter | dict[str, Any] | None = None,
) int

Find approximate property count for time series.

Parameters:
  • property (TimeSeriesProperty | str | list[str]) – The property to count the cardinality of.

  • advanced_filter (Filter | dict[str, Any] | None) – The filter to narrow down the time series to count cardinality.

  • aggregate_filter (AggregationFilter | dict[str, Any] | None) – The filter to apply to the resulting buckets.

  • filter (TimeSeriesFilter | dict[str, Any] | None) – The filter to narrow down the time series to count requiring exact match.

Returns:

The number of properties matching the specified filters and search.

Return type:

int

Examples:

Count the number of different units used for time series in your CDF project:

>>> from cognite.client import CogniteClient
>>> from cognite.client.data_classes.time_series import TimeSeriesProperty
>>> client = CogniteClient()
>>> # async_client = AsyncCogniteClient()  # another option
>>> unit_count = client.time_series.aggregate_cardinality_values(TimeSeriesProperty.unit)

Count the number of timezones (metadata key) for time series with the word “critical” in the description in your CDF project, but exclude timezones from america:

>>> from cognite.client.data_classes import filters, aggregations as aggs
>>> from cognite.client.data_classes.time_series import TimeSeriesProperty
>>> not_america = aggs.Not(aggs.Prefix("america"))
>>> is_critical = filters.Search(TimeSeriesProperty.description, "critical")
>>> timezone_count = client.time_series.aggregate_cardinality_values(
...     TimeSeriesProperty.metadata_key("timezone"),
...     advanced_filter=is_critical,
...     aggregate_filter=not_america,
... )