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 represented as a column of type dict.
- 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() 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) sample energy num_occurrences 0 {'a': -1, 'b': 1, 'c': -1} -0.5 1 1 {'a': -1, 'b': -1, 'c': 1} -0.5 1
Note that sample sets can be constructed to contain data structures incompatible with the target Pandas format.