Skip to content

Instantly share code, notes, and snippets.

@infinite-Joy
Created September 20, 2017 06:03
Show Gist options
  • Save infinite-Joy/edce4c41232dea5961081a981dd50e60 to your computer and use it in GitHub Desktop.
Save infinite-Joy/edce4c41232dea5961081a981dd50e60 to your computer and use it in GitHub Desktop.
# Groupby states
df_state = df.drop('Year', axis=1)
df_state = df_state.groupby('State', as_index=False).agg({'Total': 'sum'})
print(df_state.head())
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment