Aggregate Event Values Cardinality
- async AsyncCogniteClient.events.aggregate_cardinality_values(
- property: EventProperty | str | list[str],
- advanced_filter: Filter | dict[str, Any] | None = None,
- aggregate_filter: AggregationFilter | dict[str, Any] | None = None,
- filter: EventFilter | dict[str, Any] | None = None,
Find approximate property count for events.
- Parameters:
property (EventPropertyLike) – The property to count the cardinality of.
advanced_filter (Filter | dict[str, Any] | None) – The filter to narrow down the events to count cardinality.
aggregate_filter (AggregationFilter | dict[str, Any] | None) – The filter to apply to the resulting buckets.
filter (EventFilter | dict[str, Any] | None) – The filter to narrow down the events to count requiring exact match.
- Returns:
The number of properties matching the specified filter.
- Return type:
int
Examples:
Count the number of types of events in your CDF project:
>>> from cognite.client import CogniteClient >>> from cognite.client.data_classes.events import EventProperty >>> client = CogniteClient() >>> # async_client = AsyncCogniteClient() # another option >>> type_count = client.events.aggregate_cardinality_values(EventProperty.type)
Count the number of types of events linked to asset 123 in your CDF project:
>>> from cognite.client.data_classes import filters >>> from cognite.client.data_classes.events import EventProperty >>> is_asset = filters.ContainsAny(EventProperty.asset_ids, 123) >>> plain_text_author_count = client.events.aggregate_cardinality_values( ... EventProperty.type, advanced_filter=is_asset ... )