0

I have a dataframe with columns like this

category               label    
POLITICS                 0  
WELLNESS                 1  
ENTERTAINMENT            2  
STYLE & BEAUTY           3  
TRAVEL                   4  
PARENTING                5  
FOOD & DRINK             6  
...

I want to select the rows containing labels, say 0 to 3.

I can do it like this but it is very manual. I may have some 20 rows to select.

df.loc[(df.label == 0)|(df.label == 1)|(df.label == 2)|(df.label == 3)....

is there a better way?

Bluetail
  • 1,093
  • 2
  • 13
  • 27

0 Answers0