Skip to content
Advertisement

How to split a 2d numpy array vertically into a new 2d numpy array?

I have this code that essentially splits a two-dimensional numpy array horizontally and makes a new two-dimensional numpy array out of it.

JavaScript

Output of my code:

JavaScript

How can I do this with less lines of code? I assume it could be very resource intensive, as soon as I apply this example to my larger task.

Advertisement

Answer

I suppose using numpy.hsplit in this case is not necessary and what I am trying to do is covered by the numpy.transpose function.

JavaScript

Thank you j1-lee for pointing this out.

User contributions licensed under: CC BY-SA
10 People found this is helpful
Advertisement