numpy arrays
Chris Angelico
rosuav at gmail.com
Wed Mar 23 06:35:38 EDT 2016
On Wed, Mar 23, 2016 at 9:06 PM, Heli <hemla21 at gmail.com> wrote:
> I have a 2D numpy array like this:
>
> [[1,2,3,4],
> [1,2,3,4],
> [1,2,3,4]
> [1,2,3,4]]
>
> Is there any fast way to convert this array to
>
> [[1,1,1,1],
> [2,2,2,2]
> [3,3,3,3]
> [4,4,4,4]]
What you want is called *transposing* the array:
http://docs.scipy.org/doc/numpy/reference/generated/numpy.transpose.html
That should be a sufficiently fast operation.
ChrisA
More information about the Python-list
mailing list