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

Popular posts from this blog

How to connect android app to App engine -

gcc - MinGW's ld cannot perform PE operations on non PE output file -

php - display validation error message next to the textbox in codeigniter -