Created
August 28, 2022 18:09
-
-
Save eginez/11e1f079e77a72faf1805ed4d10c3449 to your computer and use it in GitHub Desktop.
pandas group by date
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
# load data index on date | |
# time series data like credit card transactions for example | |
df = pd.read_csv('~/Downloads/time_series_data.csv', index_col='Date', parse_dates=True) | |
# group by apply data and sum | |
df2 = df.groupby(pd.Grouper(freq='Y')).sum() | |
#df2 now contains sumarized data | |
# show perenctiles for example | |
df2.quantile([0.1, 0.5, 0.8, 0.9, 0.95]) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment