How to access the ith column of a NumPy multidimensional array?
Asked 07 September, 2021
Viewed 1.7K times
  • 47
Votes

Suppose I have:

test = numpy.array([[1, 2], [3, 4], [5, 6]])

test[i] gets me ith line of the array (eg [1, 2]). How can I access the ith column? (eg [1, 3, 5]). Also, would this be an expensive operation?

8 Answer