The dataset that I am working with has 5 US territories included under the State column, and I want to remove any row/record that has these 5 territories as the state name. I'm able to remove all the records based on one value:
indexNames = df2[df2['state'] == 'District of Columbia'].index
df2.drop(indexNames , inplace=True)
but when I do the same thing with multiple:
indexNames = df2[(df2['state'] == 'Guam') & (df2['state'] == 'Virgin Islands')].index
df2.drop(indexNames , inplace=True)
no changes take place. Is there anyway I can list all 5 in the first statement and have it work?
Edit: I decided to rename all the nonstate territories to nonstate, and then dropped the rows with the value nonstate in the state column using the following code
df2['state'] = df2['state'].replace(['District of Columbia','Guam','Mariana
Islands', 'Puerto Rico', 'Virgin Islands'],'nonstate')
indexNames = df2[df2['state'] == 'nonstate'].index
df2.drop(indexNames , inplace=True)