Aggregate Sequences Unique Values

async AsyncCogniteClient.sequences.aggregate_unique_values(
property: SequenceProperty | str | list[str],
advanced_filter: Filter | dict[str, Any] | None = None,
aggregate_filter: AggregationFilter | dict[str, Any] | None = None,
filter: SequenceFilter | dict[str, Any] | None = None,
) UniqueResultList

Get unique paths with counts for sequences.

Parameters:
  • property (SequenceProperty | str | list[str]) – The property to group by.

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

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

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

Returns:

List of unique values of sequences matching the specified filters and search.

Return type:

UniqueResultList

Examples

Get the timezones (metadata key) with count for your sequences in your CDF project:

>>> from cognite.client import CogniteClient
>>> from cognite.client.data_classes.sequences import SequenceProperty
>>> client = CogniteClient()
>>> # async_client = AsyncCogniteClient()  # another option
>>> result = client.sequences.aggregate_unique_values(
...     SequenceProperty.metadata_key("timezone")
... )
>>> print(result.unique)

Get the different metadata keys with count used for sequences created after 2020-01-01 in your CDF project:

>>> from cognite.client.data_classes import filters
>>> from cognite.client.data_classes.sequences import SequenceProperty
>>> from cognite.client.utils import timestamp_to_ms
>>> from datetime import datetime
>>> created_after_2020 = filters.Range(
...     SequenceProperty.created_time, gte=timestamp_to_ms(datetime(2020, 1, 1))
... )
>>> result = client.sequences.aggregate_unique_values(
...     SequenceProperty.metadata, advanced_filter=created_after_2020
... )
>>> print(result.unique)

Get the different metadata keys with count for sequences updated after 2020-01-01 in your CDF project, but exclude all metadata keys that starts with “test”:

>>> from cognite.client.data_classes.sequences import SequenceProperty
>>> from cognite.client.data_classes import aggregations as aggs, filters
>>> not_test = aggs.Not(aggs.Prefix("test"))
>>> created_after_2020 = filters.Range(
...     SequenceProperty.last_updated_time, gte=timestamp_to_ms(datetime(2020, 1, 1))
... )
>>> result = client.sequences.aggregate_unique_values(
...     SequenceProperty.metadata,
...     advanced_filter=created_after_2020,
...     aggregate_filter=not_test,
... )
>>> print(result.unique)