Skip to main content

転置(transpose)

Python

py
arr2 = map(list, zip(*arr1))
py
items = [
[11, 12, 13],
[21, 22, 23],
[31, 32, 33],
[41, 42, 43],
]
expected = [
[11, 21, 31, 41],
[12, 22, 32, 42],
[13, 23, 33, 43],
]

actual = map(list, zip(*items))

print(expected == actual) # => True