0

I have a dataframe:

Code   Type   Flag    Value
 ab     MAS    A        1
 ab     MAS    B        1
 cd     FF4    A        2
 cd     FF4    B        2
 xy     67G    A        90
 xy     67G    B        90

I need to drop rows when I groupby the Code, Type and Value columns where the Flag value is B.

Is there a way to drop rows based on the aggregated field in the groupby syntax?

df = df.groupby(['Code', 'Type', 'Value'])['Flag' != 'B'] This code is probably very wrong but its just for explanation purposes.

So this is the output:

Code   Type   Flag    Value
 ab     MAS    A        1
 cd     FF4    A        2
 xy     67G    A        90
Mazz
  • 770
  • 3
  • 11
  • 23

0 Answers0