I have a csv file(or dataframe) like below :
Text Location State
A Florida, USA Florida
B NY New York
C
D abc
And a dictionary with key value pair as :
stat_map = {
'FL': 'Florida',
'NY': 'New York',
'AR': 'Arkansas',
}
How may I delete row 3rd and 4th i.e. row with Text C & D so that my dataframe contains only those rows for which i have value in dictionary. All rows for which state is either blank or has some value which is not in dictionary value should be deleted. The final output should look like :
Text Location State
A Florida, USA Florida
B NY New York
Please help.
Use
extract
+replace
, last remove rows bydropna
: