I have a df that has a column of city names and a column with crashes (integer) column where the city column has a correct spelling but also has misspellings of each. I created a list of each city's correct spelling and trying to filter out the misspelled rows. But the code I've tried so far isn't filtering out the misspelled rows. My searches on how to do this lead to using isin.
Here is part of my city list:
city_list = [('Aberdeen', 'Ahoskie', 'Alamance', 'Albermarle',...
Here are some attempts:
df = df[~df['city'].isin(city_list)]
df = df[df['city'].apply(lambda x: tuple([y.lower() for y in x])).isin(city_list)]
df = df[np.isin(df['city'], city_list)]
So I want to filter out 'Aberdee' and keep 'Aberdeen' as an example:
city crash_1
915 ABERDEE 1
97 ABERDEEN 587
916 ABSHERS 1
917 ACME 1
Much obliged for any help.