Avv
Avv

Reputation: 519

Array notation in numpy

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]])

Upvotes: 1

Views: 59

Answers (1)

Nurislom Rakhmatullaev
Nurislom Rakhmatullaev

Reputation: 315

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]

Upvotes: 2

Related Questions