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
  • 38,409
  • 6
  • 31
  • 57

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,263
  • 2
  • 10
  • 29