1

In Numpy,

What is the difference between

import numpy as np
arry = np.array([1,2,3])

and

import numpy as np
arry = np.array([[1,2,3]])
1
  • you have an extra dimension defined in the second one. First one is a 1d array, second one is 2d. Verify with arry.shape Commented Feb 19, 2021 at 16:00

1 Answer 1

2

First one is 1D array. Second one is 2d array.
Fist one doesn't have a columns. So you can pick an element by

arry[0]

But the second one you should pick a column, like

arry[0, 0]

For 2D and higher:

arry[row_number, column_number]
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.