dimod.SampleSet.to_pandas_dataframe

SampleSet.to_pandas_dataframe(sample_column=False)[source]

Convert a sample set to a Pandas DataFrame

Parameters:
  • sample_column (bool, optional, default=False) – If True, samples are
  • as a column of type dict. (represented) –
Returns:

pandas.DataFrame

Examples

>>> samples = dimod.SampleSet.from_samples([{'a': -1, 'b': +1, 'c': -1},
...                                         {'a': -1, 'b': -1, 'c': +1}],
...                                        dimod.SPIN, energy=-.5)
>>> samples.to_pandas_dataframe()    # doctest: +SKIP
   a  b  c  energy  num_occurrences
0 -1  1 -1    -0.5                1
1 -1 -1  1    -0.5                1
>>> samples.to_pandas_dataframe(sample_column=True)    # doctest: +SKIP
                       sample  energy  num_occurrences
0  {'a': -1, 'b': 1, 'c': -1}    -0.5                1
1  {'a': -1, 'b': -1, 'c': 1}    -0.5                1