Last active
January 12, 2021 02:59
-
-
Save justinhchae/554e6be50c35bb9f24b82e6ff545384c to your computer and use it in GitHub Desktop.
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
freq='M' | |
# or 'D' or 'Y' | |
df = df[['dates', 'types']].groupby([pd.Grouper(key='dates', freq=freq)]).agg('count').reset_index() | |
""" | |
dates count | |
2 2012-07-31 0 | |
1 2012-06-30 1 | |
3 2012-08-31 1 | |
0 2012-05-31 2 | |
""" | |
# group by the category being counted, or count in this case | |
group = df.groupby('count') | |
print(group) | |
""" | |
<pandas.core.groupby.generic.DataFrameGroupBy object at 0x7fc04f3b9cd0> | |
""" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment