Last answered:

08 Jan 2024

Posted on:

23 Dec 2023

0

2:40 - what's the difference between X_std[y==3,:] & X_std[y==3] used earlier? aren't they the same 

2:40 - what's the difference between X_std[y==3,:] & X_std[y==3] used earlier? aren't they the same 



1 answers ( 0 marked as helpful)
Instructor
Posted on:

08 Jan 2024

0

Hi Ryan!

Thanks for reaching out!

Yes, both expressions will give you the same result: the rows of X_std where y==3 is True. However, it's a matter of coding style and personal preference. Some people prefer using the colon : to explicitly indicate that they are selecting all columns, while others omit it for brevity.

In summary, both expressions are used to select rows from a NumPy array based on a condition, and they are often interchangeable in practice.

Hope this helps.

Best,

Ivan

Submit an answer