1

Hi I am trying to remove a row if column value is equal to more than one value. The following example shows how to compare one value to delete. For example I want to remove if my column value is "a1" or "b1" Also my column header name is 'Sky Product' which has space in between and hence i have used this method. Thanks.

df = df[df['Sky Product'] != 'a1']
Sociopath
  • 13,068
  • 19
  • 47
  • 75
Lilly
  • 910
  • 17
  • 38

2 Answers2

1

I think you need:

df = df[~df["Sky Product"].isin(["a1","b1"])]
Sociopath
  • 13,068
  • 19
  • 47
  • 75
0

Try using:

df = df[(df['Sky Product']!= 'a1') & (df['Sky Product']!= 'b1')]

Or if you have too many values to separate them as such, you can together do:

r=['a1','b1',....]
df[~df['Sky Product'].isin(r)]
wookiekim
  • 1,156
  • 7
  • 20