Skip to content

Instantly share code, notes, and snippets.

@AnnikaNoren
Created August 8, 2020 19:20
Show Gist options
  • Save AnnikaNoren/cc724a377c400b4cd874d1137db6f26d to your computer and use it in GitHub Desktop.
Save AnnikaNoren/cc724a377c400b4cd874d1137db6f26d to your computer and use it in GitHub Desktop.
zipcode_lat_dict.py
# Create df with zip code as index and mean latitude value for each zip code
no_index_zip_lat = df.groupby('zipcode', as_index=True)['lat'].mean()
# Convert the data frame to a dict, the zip is the key and mean latitude is the value
zip_lat_dict = no_index_zip_lat.to_dict()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment