I've been trying to convert a numpy rec.array into a dataframe. The current array looks like:
[rec.array([([0.2], [ 1.76405235, 0.40015721, 0.97873798, 2.2408932 ]),
([0.2], [ 1.86755799, -0.97727788, 0.95008842, -0.15135721]),
([0.2], [-0.10321885, 0.4105985 , 0.14404357, 1.45427351]),
([0.2], [ 0.76103773, 0.12167502, 0.44386323, 0.33367433]),
([0.2], [ 1.49407907, -0.20515826, 0.3130677 , -0.85409574])],
dtype=[('weights', '<f8', (1,)), ('integration', '<f8', (4,))]),
rec.array([([0.1], [ 1.76405235, 0.40015721, 0.97873798, 2.2408932 ]),
([0.1], [ 1.86755799, -0.97727788, 0.95008842, -0.15135721]),
([0.1], [-0.10321885, 0.4105985 , 0.14404357, 1.45427351]),
([0.1], [ 0.76103773, 0.12167502, 0.44386323, 0.33367433]),
([0.1], [ 1.49407907, -0.20515826, 0.3130677 , -0.85409574]),
([0.1], [-2.55298982, 0.6536186 , 0.8644362 , -0.74216502]),
([0.1], [ 2.26975462, -1.45436567, 0.04575852, -0.18718385]),
([0.1], [ 1.53277921, 1.46935877, 0.15494743, 0.37816252]),
([0.1], [-0.88778575, -1.98079647, -0.34791215, 0.15634897]),
([0.1], [ 1.23029068, 1.20237985, -0.38732682, -0.30230275])],
dtype=[('weights', '<f8', (1,)), ('integration', '<f8', (4,))]),
rec.array([([0.16666667], [ 1.76405235, 0.40015721, 0.97873798, 2.2408932 ]),
([0.16666667], [ 1.86755799, -0.97727788, 0.95008842, -0.15135721]),
([0.16666667], [-0.10321885, 0.4105985 , 0.14404357, 1.45427351]),
([0.16666667], [ 0.76103773, 0.12167502, 0.44386323, 0.33367433]),
([0.16666667], [ 1.49407907, -0.20515826, 0.3130677 , -0.85409574]),
([0.16666667], [-2.55298982, 0.6536186 , 0.8644362 , -0.74216502])],
dtype=[('weights', '<f8', (1,)), ('integration', '<f8', (4,))]),
rec.array([([0.05882353], [ 1.76405235, 0.40015721, 0.97873798, 2.2408932 ]),
([0.05882353], [ 1.86755799, -0.97727788, 0.95008842, -0.15135721]),
([0.05882353], [-0.10321885, 0.4105985 , 0.14404357, 1.45427351]),
([0.05882353], [ 0.76103773, 0.12167502, 0.44386323, 0.33367433]),
([0.05882353], [ 1.49407907, -0.20515826, 0.3130677 , -0.85409574]),
([0.05882353], [-2.55298982, 0.6536186 , 0.8644362 , -0.74216502]),
([0.05882353], [ 2.26975462, -1.45436567, 0.04575852, -0.18718385]),
([0.05882353], [ 1.53277921, 1.46935877, 0.15494743, 0.37816252]),
([0.05882353], [-0.88778575, -1.98079647, -0.34791215, 0.15634897]),
([0.05882353], [ 1.23029068, 1.20237985, -0.38732682, -0.30230275]),
([0.05882353], [-1.04855297, -1.42001794, -1.70627019, 1.9507754 ]),
([0.05882353], [-0.50965218, -0.4380743 , -1.25279536, 0.77749036]),
([0.05882353], [-1.61389785, -0.21274028, -0.89546656, 0.3869025 ]),
([0.05882353], [-0.51080514, -1.18063218, -0.02818223, 0.42833187]),
([0.05882353], [ 0.06651722, 0.3024719 , -0.63432209, -0.36274117]),
([0.05882353], [-0.67246045, -0.35955316, -0.81314628, -1.7262826 ]),
([0.05882353], [ 0.17742614, -0.40178094, -1.63019835, 0.46278226])]],
dtype=[('weights', '<f8', (1,)), ('integration', '<f8', (4,))])]
The result should be a five-column dataframe like the following:
| Weights | v_1 | v_2 | v_3 | v_4 |
|---|---|---|---|---|
| 0.2 | 1.76405235 | 0.40015721 | 0.97873798 | 2.2408932 |
| 0.2 | 1.86755799 | -0.97727788 | 0.95008842 | -0.15135721 |
| .... | .... | ... | ... | ... |
| 0.05882353 | 0.17742614 | -0.40178094 | -1.63019835 | 0.46278226 |
and so on..
However, as I do pd.DataFrame(my_list), the resulting dataframe has like 90 columns and not 5 as the above. Each column represents a sublist of the array of the form [a], [w, x, y, z]. The resulting dataframe should be: 5 columns and number of rows equal to 32 (for the above example).
[a], [w, x, y, z]. I think these are the five columns. For example, in[0.2], [ 1.76405235, 0.40015721, 0.97873798, 2.2408932 ]- 0.2 is first column, 1.76405235 is second column, etc.