Last active
May 17, 2021 20:55
-
-
Save bruno-uy/035dab09f723d369103d57cedbd575de to your computer and use it in GitHub Desktop.
Date frequency group by month
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
import pandas as pd | |
# Create sample pandas.Series to calculate frequency | |
s = pd.Series(pd.date_range("2021", freq="18H", periods=1000)) | |
# Calculate frequency grouping by month | |
# If you want another period check following link: | |
# https://pandas.pydata.org/docs/user_guide/timeseries.html#timeseries-offset-aliases | |
freq_count = s.dt.to_period("M").value_counts(sort=False) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment