Because I always forget how to do the same things, over and over again
See also: R stats cheat sheet
Helpful links:
Count instances of variables within groups
df.value_counts(subset=['county', 'category']).to_frame(name='n').reset_index()
Mutate a grouped data frame
df['pct'] = df['n'] / df.groupby('county')['n'].transform('sum')
Sort by columns
df.sort_values(['col1', 'col2'])
df.sort_values('col1', ascending=False)
df.sort_values(['col1', 'col2'], ascending=[True, False])
Show all rows/columns of a dataframe
with pd.option_context('display.max_rows', None, 'display.max_columns', None):
display(df)
Convert a series to a dataframe for better printing
series.to_frame(name'col_name')