Is there any fast method to make a transposition of a rectangular 2D matrix in Python (non-involving any library import).?
Say, if I have an array
X=[ [1,2,3],
[4,5,6] ]
I need an array Y which should be a transposed version of X, so
Y=[ [1,4],
[2,5],
[3,6] ]
Simple: Y=zip(*X)
EDIT: to answer questions in the comments about what does zip(*X) mean, here is an example from python manual:
So, when
Xis[[1,2,3], [4,5,6]],zip(*X)iszip([1,2,3], [4,5,6])