Skip to content

Instantly share code, notes, and snippets.

@ReidWilliams

ReidWilliams/pandas.txt

Last active Feb 22, 2018
Embed
What would you like to do?
Pandas cheatsheet
# rename a dataframe column
dataframe = dataframe.rename(index=str, columns={'old_col_name': 'new_col_name'})
# get all possible values for a string / categorical column
dataframe[column].value_counts(dropna=False)
# group data and count number of rows in a group
grouped = dataframe.groupby(color)
nreds = len(grouped.get_group('red'))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.