I'm trying to convert U.S. geolocation codes for states, counties and cities. The problem is, the county and city codes are duplicated -- meaning, multiple states have counties and cities with the same code. And I'm dealing with separate dataframes.
The main df has rows that look like this:
State CountyCode CityCode Data
Alabama 61 2720 3
And I've put the downloaded codes into a separate df2 that looks like this:
State CountyCode County CityCode City
Alabama 61 Henry 2720 Albertville
What I want is a df that looks like this:
State CountyCode County CityCode City Data
Alabama 61 Henry 2720 Albertville 3
My question is how to do this. I've put the rows in df2 into a series, dictionary, list. I've tried map() and apply() and iterating through df, but nothing has quite worked. For one thing, to convert the county and city codes, I need the state as well as the local name. I assume there is a better way to do this, conceptually, and that I'm just not aware of it. Many thanks for any help.