# qiskit - Creating your own ExperimentResultData object

Could someone guide me on how to create my own qiskit.result.models.ExperimentResultData object? I would simply like to create an object with some self-created dict of counts.

Creating qiskit.result.models.ExperimentalResults object is somehow easy, since by calling it from qiskit.result.models.ExperimentResults, I simply pass the required attributes. But somehow I was not able to figure out how to do the same with qiskit.result.models.ExperimentResultData, which should be passed as "data" attribute to qiskit.result.models.ExperimentalResults object.

## 1 Answer

You should be able to do this by simply creating an instance of the class. This can be done as follows

from qiskit.validation import base
raw_counts = {'0x0': 4, '0x2': 10}
data = models.ExperimentResultData(counts=base.Obj(**raw_counts))


There are lot of examples of how to do this in the testing file for these classes.

• Ah, great, thank you for the solution and great reference! I was only looking at files in the qiskit package (downloaded via pip) and I did not find such testing file, so I'll use github one for future issues. Nov 21 '19 at 17:08
• @FilipMaciejewski If this answer helped, consider accepting it by clicking on the checkmark at the left. Nov 21 '19 at 17:24