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

PHP DOM loadHTML() method unusual warning -

python - How to create jsonb index using GIN on SQLAlchemy? -

c# - TransactionScope not rolling back although no complete() is called -