Reputation: 16050
I have a pandas data frame. I need to select Score
for those entries that have column's Ind
values equal to 0.
Score = df[df['Ind'] == 0]['Score']
How can I do this?
Upvotes: 1
Views: 358
Reputation: 394031
Use loc
:
Score = df.loc[df['Ind']==0, 'Score']
So we pass the boolean condition as the first param and then col of interest.
The boolean condition generates a boolean mask that is used to mask the index against so will only return those rows.
The docs give various examples of indexing
Upvotes: 1