Aggregate Asset Value Cardinality
- async AsyncCogniteClient.assets.aggregate_cardinality_values(
- property: AssetProperty | str | list[str],
- advanced_filter: Filter | dict[str, Any] | None = None,
- aggregate_filter: AggregationFilter | dict[str, Any] | None = None,
- filter: AssetFilter | dict[str, Any] | None = None,
Find approximate property count for assets.
- Parameters:
property (AssetPropertyLike) – The property to count the cardinality of.
advanced_filter (Filter | dict[str, Any] | None) – The advanced filter to narrow down assets.
aggregate_filter (AggregationFilter | dict[str, Any] | None) – The filter to apply to the resulting buckets.
filter (AssetFilter | dict[str, Any] | None) – The filter to narrow down assets (strict matching).
- Returns:
The number of properties matching the specified filters and search.
- Return type:
int
Examples
Count the number of labels used by assets in your CDF project:
>>> from cognite.client import CogniteClient >>> from cognite.client.data_classes.assets import AssetProperty >>> client = CogniteClient() >>> # async_client = AsyncCogniteClient() # another option >>> label_count = client.assets.aggregate_cardinality_values(AssetProperty.labels)
Count the number of timezones (metadata key) for assets with the word “critical” in the description in your CDF project:
>>> from cognite.client.data_classes.filters import Search >>> from cognite.client.data_classes.assets import AssetProperty >>> is_critical = Search(AssetProperty.description, "critical") >>> critical_assets = client.assets.aggregate_cardinality_values( ... AssetProperty.metadata_key("timezone"), advanced_filter=is_critical ... )