Skip to content

Instantly share code, notes, and snippets.

@ankailou
Created February 1, 2017 20:41
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 ankailou/a70853ead0f3d2280bd28a59bd1c5acd to your computer and use it in GitHub Desktop.
Save ankailou/a70853ead0f3d2280bd28a59bd1c5acd to your computer and use it in GitHub Desktop.
Example of agg
import pandas as pd
df = pd.DataFrame({ 'color' : ['Blue', 'Blue', 'Green'], 'name' : ['Bernard', 'Bernard', 'Bernard']})
print df.groupby(['name']).agg(lambda x:x.value_counts().index[0])
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment