Skip to content Skip to sidebar Skip to footer

Is There A Way To Reverse The Dropping Method In Pandas?

I'm aware that you can use df1 = df1[df1['Computer Name'] != 'someNameToBeDropped'] to drop a given string as a row what if i wanted to do it the other way around. Let's say dropp

Solution 1:

Try this to get rows such that value of col is in that given list

df = df[df[column].isin(list_of_strings)]

Additional to exclude what's in the list

df = df[~df[column].isin(list_of_values)]

Post a Comment for "Is There A Way To Reverse The Dropping Method In Pandas?"