Forum

Notifications
Clear all

LIB-3 Pandas Foundation  

   RSS

0

Why is there a need to use the .loc in this case?  "To filter the 'US' population from the 'origin' column, you need to specify 'origin' == 'US' inside your call to df.loc[]."

 

The correct answer given was us = df.loc[df['origin'] == 'US'] 

 

Wouldn't df[df['origin'] == 'US'] work just as well?

This topic was modified 1 month ago by jingdalim
1 Answer
0

Both work. df.loc is the standard way though.

Share:

Delete your account