0

We have an array

a = [[1, 2, 3],[4, 5, 6],[7, 8, 9]]

and looking for array:

b = [[1, 4, 7],[2, 5, 8],[3, 6, 9]]

Thank you!

Nick Parsons
  • 45,728
  • 6
  • 46
  • 64

1 Answers1

0

Try with numpy.transpose(). See below:

import numpy as np

a = [[1, 2, 3],[4, 5, 6],[7, 8, 9]]

[list(i) for i in np.array(a).transpose()]

Output:

[[1, 4, 7], [2, 5, 8], [3, 6, 9]]
IoaTzimas
  • 10,538
  • 2
  • 13
  • 30