Suppose I have a DF:
DF:
Inp | M | N | P
GF | 1 | 12 |
GF | 1 | 12 |
GF | 1 | 13 |
and I want to place a value in any rows where Inp
= GF
and M
= 1 and N
= 12 to get an output like this:
DF2:
Inp | M | N | P
GF | 1 | 12 | X
GF | 1 | 12 | X
GF | 1 | 13 |
I know I can select by multiple attributes using .loc
like this:
df.loc[(DF['Inp'] = 'GF') & (DF['M'] = 1) & (DF['N'] = 12)]
But I'm not sure how to then place a value in column P. Maybe I'm not on the right track.