Histogram

async AsyncCogniteClient.data_modeling.instances.histogram(
view: ViewId,
histograms: Histogram | Sequence[Histogram],
instance_type: Literal['node', 'edge'] = 'node',
query: str | None = None,
properties: SequenceNotStr[str] | None = None,
target_units: list[TargetUnit] | None = None,
space: str | SequenceNotStr[str] | None = None,
filter: Filter | dict[str, Any] | None = None,
limit: int = 25,
) HistogramValue | list[HistogramValue]

Produces histograms for nodes/edges.

Parameters:
  • view (ViewId) – View to to aggregate over.

  • histograms (Histogram | Sequence[Histogram]) – The properties to aggregate over.

  • instance_type (Literal['node', 'edge']) – Whether to search for nodes or edges.

  • query (str | None) – Query string that will be parsed and used for search.

  • properties (SequenceNotStr[str] | None) – Optional array of properties you want to search through. If you do not specify one or more properties, the service will search all text fields within the view.

  • target_units (list[TargetUnit] | None) – Properties to convert to another unit. The API can only convert to another unit if a unit has been defined as part of the type on the underlying container being queried.

  • space (str | SequenceNotStr[str] | None) – Restrict histogram query to instances in the given space (or list of spaces).

  • filter (Filter | dict[str, Any] | None) – Advanced filtering of instances.

  • limit (int) – Maximum number of instances to return. Defaults to 25.

Returns:

Node or edge aggregation results.

Return type:

HistogramValue | list[HistogramValue]

Examples

Find the number of people born per decade:

>>> from cognite.client import CogniteClient
>>> from cognite.client.data_classes.aggregations import Histogram
>>> from cognite.client.data_classes.data_modeling import ViewId
>>> client = CogniteClient()
>>> # async_client = AsyncCogniteClient()  # another option
>>> birth_by_decade = Histogram("birthYear", interval=10.0)
>>> view_id = ViewId("mySpace", "PersonView", "v1")
>>> res = client.data_modeling.instances.histogram(view_id, birth_by_decade)