dimod icon indicating copy to clipboard operation
dimod copied to clipboard

`SampleSet.to_pandas_dataframe` fails for record arrays with fields of more than one dimension

Open arcondello opened this issue 4 years ago • 1 comments

https://github.com/dwavesystems/dimod/pull/963 was an attempt to fix this issue, but that approach fails. More investigation needed.

Failing examples

        samples = dimod.SampleSet(
            np.rec.array([([0.], 1., 1,  True, [])],
                         dtype=[('sample', '<f8', (1,)), ('energy', '<f8'),
                                ('num_occurrences', '<i4'), ('thing1', '?'),
                                ('thing2', '?', (0,))]),
            ['a'], {}, 'INTEGER')
        samples = dimod.SampleSet(
            np.rec.array([([0.], 1., 1,  True, []), [([0.], 1., 1,  True, []), [([0.], 1., 1,  True, [])],
                         dtype=[('sample', '<f8', (1,)), ('energy', '<f8'),
                                ('num_occurrences', '<i4'), ('thing1', '?'),
                                ('thing2', '?', (0,))]),
            ['a'], {}, 'INTEGER')

arcondello avatar Aug 23 '21 19:08 arcondello

Note that pandas.DataFrame.from_records also fails for this case with Exception: Data must be 1-dimensional.

arcondello avatar Aug 23 '21 20:08 arcondello