Hello, I am a beginner in pandas and I have a problem that I did not find / understood how to solve in the documentation or other topics. Briefly I need to group the days of my database observations within five days, and for each interval calculate the average occurrence of accidents, I'm trying unsuccessfully something like:
df = df.groupby(pd.TimeGrouper('5D'))['Acidentes'].mean()
Data Hora Acidentes Vítimas ... 0 12/02/2017 00 0 0 1 12/02/2017 01 2 1 ... 24 13/02/2017 00 1 0 25 13/02/2017 01 0 0 ... 95 30/04/2017 23 3 2
These occurrences are recorded by day and by hour, but the intention is to group by a range of days and then average the number of accidents for each interval.