python - Unwrap inner array from a NumPy array -
how can transform numpy
array:
[[[10 10]] [[300 300]] [[10 300]]]
into one:
[[[ 10 10] [300 300] [ 10 300]]]
you can use advanced indexing slice first item of subarrays , wrap in outer array:
a = numpy.array([[[10, 10]], [[300, 300]], [[10, 300]]]) b = numpy.array([a[:,0]]) print(b)
prints
[[[ 10 10] [300 300] [ 10 300]]]
or, using swapaxes
:
b = numpy.swapaxes(a, 1, 0)
Comments
Post a Comment