Skip to content

Instantly share code, notes, and snippets.

@trungkak
Created August 6, 2018 11:30
Show Gist options
  • Save trungkak/72889e11191923c41df91f223239df39 to your computer and use it in GitHub Desktop.
Save trungkak/72889e11191923c41df91f223239df39 to your computer and use it in GitHub Desktop.
# 1. Adding a 'count' column to the result of a groupby in pandas? (https://goo.gl/WMr1zJ)
df.groupby(['A','B']).size().to_frame('count').reset_index()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment