Note

This is the documentation for the current state of the development branch of Qiskit Experiments. The documentation or APIs here can change prior to being released.

AnalysisResultTable

class AnalysisResultTable[source]

A table-like dataset for analysis results.

Default table columns are defined in the class attribute DEFAULT_COLUMNS. The table is automatically expanded when an extra key is included in the input dictionary data. Missing columns in the input data are filled with a null value.

Table row index (i.e. entry ID) is created by truncating the result_id string which is basically a UUID-4 string. A random unique ID is generated when the result_id is missing in the input data.

Any operation on the table value via the instance methods guarantees thread safety.

Create new dataset.

Attributes

DEFAULT_COLUMNS = ['name', 'experiment', 'components', 'value', 'quality', 'experiment_id', 'result_id', 'tags', 'backend', 'run_time', 'created_time']
VALID_ID_REGEX = re.compile('\\A(?P<short_id>\\w{8})-\\w{4}-\\w{4}-\\w{4}-\\w{12}\\Z')
columns

All columns in current dataset.

dataframe

Dataframe object of analysis results.

result_ids

Result IDs in current dataset.

Methods

__len__()[source]
add_data(*, result_id=None, **data)[source]

Add new data to this dataset.

Parameters:
  • result_id (str | None) – A unique UUID-4 string for this data entry. The full string is used to identify the data in the experiment service database, and a short ID is created by truncating this string as a dataframe index.

  • data – Arbitrary key-value pairs representing a single data entry. Missing values for default columns are filled with None.

Returns:

Assigned analysis result ID.

Return type:

str

clear()[source]

Clear all table entries.

copy()[source]

Create new thread-safe instance with the same data.

Note

This returns a new object with shallow copied data frame.

del_data(key)[source]

Delete matched entries from this dataset.

Parameters:

key (str | int) – Identifier of the entry of interest.

Returns:

Deleted analysis result IDs.

Return type:

list[str]

classmethod from_dataframe(data)[source]

Create new dataset with existing dataframe.

Parameters:

data (DataFrame) – Bare dataframe object.

Returns:

A new AnalysisResults instance.

Return type:

AnalysisResultTable

get_data(key=None, columns='default')[source]

Get matched entries from this dataset.

Parameters:
  • key (str | int | slice | None) – Identifier of the entry of interest.

  • columns (str | list[str]) – List of names or a policy (default, minimal, all) of data columns included in the returned data frame.

Returns:

Matched entries in a single data frame or series.

Return type:

DataFrame