1

When using a numpy array as a matrix, in which order are rows and columns?

For example:

array([[1, 2, 3],
       [4, 5, 6],
       [7, 8, 9]])

Is [1, 2, 3] the first row or the first column?

I cannot find this information in the documentation, perhaps because the answer is too obvious.

1
  • 1
    The order is the obvious one Commented Oct 23, 2019 at 7:14

1 Answer 1

1

[1, 2, 3] is the first row.

The examples in numpy ndarray documentation actually gives you some hints:

>>> x = np.array([[1, 2, 3], [4, 5, 6]], np.int32)

>>> # The element of x in the *second* row, *third* column, namely, 6.
>>> x[1, 2] ```
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.