Having Trouble Understanding NumPy Indexing

I’m on the boolean indexing portion of the Python for Data Science career track. In track #8, the following numpy array is shown:

c = np.array([[1,2,3],

And if we wanted to change the values in this array that are in the second column, and greater than 2, to 99, we would use the boolean indexing:

c[c[:,1] > 2,1] = 99

Intuitively, I would’ve guessed you would’ve been able to do the same type of filtering using the following command:

c[c[:,1] > 2] = 99

Why is that not possible?


numpy multi-dimension array indexing sometimes is quite complicated. I believe in numpy multi-dimensional array each row has two-number indexing, not one number indexing as we see in pandas.
So [0,0] means 0 indexing for rows.
array[[0,2],[0,2]] means 0, 2 column indexing.

Give you an example.

If you have more interests finding out multi-dimension array indexing, you can google + stackoverflow.

Here is a good article. Hope it helps.