Skip to content

Instantly share code, notes, and snippets.

@BinarySpoon
Last active October 23, 2020 10:14
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 BinarySpoon/73eff24708275a234923d5a890560006 to your computer and use it in GitHub Desktop.
Save BinarySpoon/73eff24708275a234923d5a890560006 to your computer and use it in GitHub Desktop.
# Tag University Towns As True -->
uni_regions = get_list_of_university_towns()
uni_regions['Uni_regions'] = True
# merge housing data with uni_town df --?
data2 = pd.merge(housing_data,uni_regions,how='right', left_index=True,right_on=['State', 'RegionName'])
uni_towns = data2[data2['Uni_regions']==True]['Delta']
# merge housing data with non-uni_town df -->
data3 = pd.merge(data,uni_regions,how='left',left_index=True,right_on=['State','RegionName'])
data3['Uni_regions'] = data3['Uni_regions'].replace({np.NaN: False})
non_uni_towns = data3[data3['Uni_regions'] == False]['Delta']
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment