I have from pymoo:
variables=all_pop.get("X")
and it gets an output an nd.array that looks like that:
{'x0': 21, 'x1': 52, 'x2': 7}
{'x0': 85, 'x1': 18, 'x2': 4}
{'x0': 15, 'x1': 30, 'x2': 6}
{'x0': 22, 'x1': 58, 'x2': 7}
When I tried to take the first element of each column using
variables = pd.DataFrame(np.array(list(all_pop.get("X")[:,0])))
I had an error that said "IndexError: too many indices for array: array is 1-dimensional, but 2 were indexed".
How to create a pandas data frame that will print to excel like that?
x0 | x1 | x2 |
---|---|---|
21 | 52 | 7 |
85 | 18 | 4 |
15 | 30 | 6 |
22 | 58 | 7 |