Skip to content

Instantly share code, notes, and snippets.

@mhweber
Created July 27, 2018 21:07
Show Gist options
  • Select an option

  • Save mhweber/4b4dfbc15e417176b17cba8d92f5e4da to your computer and use it in GitHub Desktop.

Select an option

Save mhweber/4b4dfbc15e417176b17cba8d92f5e4da to your computer and use it in GitHub Desktop.
pandas groupby and aggregation example
import pandas as pd
df = pd.DataFrame({'year' : pd.Series([1961, 1961, 1961, 1962, 1962,1963, 1963]),
'value' : pd.Series([0.4, 0.5, 0.2, 0.8, 0.9, 0.8, 0.7])})
df['max_values'] = pd.Series(df.groupby('year').value.max().values)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment