Metric

Getting a metric

Do not construct a metric directly. Instead, use one of these methods on a store.

ocdsmetricsanalysis.library.Store.get_metric(self, metric_id)

Returns a specific Metric. Returns a Metric class.

ocdsmetricsanalysis.library.Store.get_metrics(self)

Returns a list of all metrics in this store. Each item in the list is a Metric class.

Class reference

class ocdsmetricsanalysis.library.Metric(store: Store, metric_id: str)

A class representing one metric from a store.

Do not construct directly; instead call other methods on a Store to get a metric.

add_aggregate_observations(data_rows: list, idx_to_aggregate: str | int, answer_dimension_key: str, idx_to_dimensions: dict = {}, unit_name: str | None = None, unit_scheme: str | None = None, unit_id: str | None = None, unit_uri: str | None = None, create_observations_from_dimensions_exponentially: bool = False)

Takes rows of data and sums up how often certain answers appear then saves new observations in the store.

add_observation(id: str, value_amount: str | None = None, value_currency: str | None = None, measure: str | None = None, dimensions: dict = {}, unit_name: str | None = None, unit_scheme: str | None = None, unit_id: str | None = None, unit_uri: str | None = None)

Adds a new single observation to this metric and saves it in the store.

get_dimension_keys() list

Returns a list of all unique dimension keys used in all observations for this metric.

get_id() str

Returns id of this Metric

get_json() dict

Get JSON for this Metric, including all observations for it.

get_observation_list()

Returns a new ObservationList object that you can use for filtered querying for observations.