# dimod.SampleSet.aggregate¶

SampleSet.aggregate()[source]

Create a new SampleSet with repeated samples aggregated.

Returns: SampleSet

Note

SampleSet.record.num_occurrences are accumulated but no other fields are.

Examples

This examples aggregates a sample set with two identical samples out of three.

>>> sampleset = dimod.SampleSet.from_samples([[0, 0, 1], [0, 0, 1],
...                                           [1, 1, 1]],
...                                           dimod.BINARY,
...                                           [0, 0, 1])
>>> print(sampleset)
0  1  2 energy num_oc.
0  0  0  1      0       1
1  0  0  1      0       1
2  1  1  1      1       1
['BINARY', 3 rows, 3 samples, 3 variables]
>>> print(sampleset.aggregate())
0  1  2 energy num_oc.
0  0  0  1      0       2
1  1  1  1      1       1
['BINARY', 2 rows, 3 samples, 3 variables]