Created
August 17, 2020 19:12
-
-
Save ayoskovich/611624523c3e81593c705a3e9229ef30 to your computer and use it in GitHub Desktop.
Create table containing counts AND proportions.
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
# 'counts' will be the name of the new column | |
# 'date' will be the index of the dataframe | |
x = df['date'].value_counts().to_frame('counts') | |
x['prop'] = x['counts'] / x['counts'].sum() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment