Skip to content

Instantly share code, notes, and snippets.

@jens-andersson-2-wcar
Created August 2, 2024 12:12
Show Gist options
  • Save jens-andersson-2-wcar/8e44e9b444a2736e77c0060e82a66b77 to your computer and use it in GitHub Desktop.
Save jens-andersson-2-wcar/8e44e9b444a2736e77c0060e82a66b77 to your computer and use it in GitHub Desktop.
Aggregating data by H3 cell; be careful with angles!
positions_df_byhex = df_subset.groupby("hex_id", as_index=False).agg({
"longitude": "mean",
"latitude": "mean",
"vector_component_x": "mean",
"vector_component_y": "mean",
"bearing": "count", # "mean" would be wrong here; we need circmean
"speed_kmh": "mean"
})
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment