Created
October 24, 2018 15:12
-
-
Save cgddrd/420878d8e2027fa7a7e8abb1f90d033e to your computer and use it in GitHub Desktop.
Pandas - Group by date and categorical column
This file contains hidden or 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
import pandas as pd | |
# 'reset_index' is required to turn a multi-level index back into columns. | |
df.groupby([pd.Grouper(key='my_date_column', freq='1D'), 'my_categorical_column']).count().reset_index() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment