Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- # To change the county names to the correct county names as much as possible
- def check_county(row):
- cl = row[["TOWN", "COUNTY"]]
- all_town = list(list_towns["TOWN"].unique())
- all_county = list(list_towns["COUNTY"].unique())
- ct = ""
- # Match the county to the town from the list_towns dataset
- if cl["TOWN"] in all_town:
- obs = list_towns[list_towns["TOWN"] == cl["TOWN"]]
- ct = obs["COUNTY"].iloc[0]
- # If town data absent, use county data if county data present
- elif ct == "":
- for i in all_county:
- if i in cl["COUNTY"]:
- ct = i
- break
- else:
- ct = cl["COUNTY"]
- return ct
- clinic["tCOUNTY"] = clinic.apply(check_county, axis = 1)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement