I have the following ndarray
:
array([[0.00000, 0.00000, 50.00000],
[0.00000, 10.02227, 50.00000],
[0.00000, 20.04454, 50.00000],
[0.00000, 30.06682, 50.00000],
[0.00000, 40.08909, 50.00000]])
and I would like to transform each row into a separate ndarray
in order to have a nested ndarray
structure:
array([[array([0.00000, 0.00000, 50.00000])],
[array([0.00000, 10.02227, 50.00000])],
[array([0.00000, 20.04454, 50.00000])],
[array([0.00000, 30.06682, 50.00000])],
[array([0.00000, 40.08909, 50.00000])]])
I've tried with:
new_array = numpy.apply_along_axis(np.array, 1, old_array)
but did not succeed because new_array
is equal to old_array
.
How can I transform my array? I guess there should be a solution using a for
cycle, but is there a more pythonic alternative?