Skip to content

Instantly share code, notes, and snippets.

@mzaradzki
Last active July 3, 2017 13:43
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 mzaradzki/40c5590224294078e4c25d6ccb807f20 to your computer and use it in GitHub Desktop.
Save mzaradzki/40c5590224294078e4c25d6ccb807f20 to your computer and use it in GitHub Desktop.
# bound of min/max latitude/longitude/height for Tanzania
bound_df = dfX[(dfX['latitude']<-0.5)&(dfX['longitude']>25)&(dfX['gps_height']>0)]
# mean of geographical data in each bucket
mean_geo_df = bound_df.groupby(['basin',])['latitude','longitude','gps_height'].mean()
assert(mean_geo_df.shape[0] == len(dfX['basin'].unique()))
# Out[31]: mean_geo_df
# latitude longitude gps_height
# basin
# Internal -4.1370 35.4715 1474.5504
# Lake Nyasa -10.021 34.7726 1524.6542
# Lake Rukwa -7.4896 31.5001 1415.1373
# Lake Tanganyika -4.9386 30.3982 1270.0632
# Lake Victoria -1.8684 34.0041 1329.2650
# Pangani -3.8493 37.5468 1102.2577
# Rufiji -8.4833 35.8520 1087.7806
# Ruvuma / Southern Coast -10.547 38.1568 455.0583
# Wami / Ruvu -6.7127 38.1703 308.9142
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment