Skip to content

Instantly share code, notes, and snippets.

@lakshay-arora
Created September 18, 2019 09:07
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 lakshay-arora/58fa758b24d0592db2613e91fdb5d769 to your computer and use it in GitHub Desktop.
Save lakshay-arora/58fa758b24d0592db2613e91fdb5d769 to your computer and use it in GitHub Desktop.
# save the top cities in a list
top_cities = ['Brooklyn','Bronx','Manhattan','Jamaica','Long Island City']
# use loc to update the target
data.loc[(data.City.isin(top_cities) == False),'City'] = 'Others'
# city value counts
data.City.value_counts()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment