Last active
February 22, 2018 14:47
-
-
Save ReidWilliams/b9166c2e2950c6bd54845e82c8adebfa to your computer and use it in GitHub Desktop.
Pandas cheatsheet
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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