Skip to content

Instantly share code, notes, and snippets.

@amankharwal
Created February 13, 2021 14:39
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save amankharwal/57361fe408a54cde36f98bd6c7f2ff48 to your computer and use it in GitHub Desktop.
Save amankharwal/57361fe408a54cde36f98bd6c7f2ff48 to your computer and use it in GitHub Desktop.
# Replacing "United Kingdom with "UK"
data.Hotel_Address = data.Hotel_Address.str.replace("United Kingdom", "UK")
# Now I will split the address and pick the last word in the address to identify the country
data["countries"] = data.Hotel_Address.apply(lambda x: x.split(' ')[-1])
print(data.countries.unique())
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment