you can delete rows based on multiple conditions within a column using python

I believe you should use isin:

df1 = df[~df['pod'].isin(['hi','no']) ]

print(df1)

Output:

   value   pod
1      2    ok
3      4  sure

On the other note, look at the following:

df.drop(df.index[df['pod'] == 'hi', 'no'], inplace = True)

if it were to work, inplace=True forces the drop command to work inplace, and return None. So

df1 = df.drop(df.index[df['pod'] == 'hi', 'no'], inplace = True)

would mean that df1 is None, not a dataframe.

CLICK HERE to find out more related problems solutions.

Leave a Comment

Your email address will not be published.

Scroll to Top