2
Hello, I’m a beginner in pandas and I caught in a problem that I didn’t find/understand how to solve in the documentation or other topics. Briefly I need to group the days of the observations from my database in an interval of five days, and for each interval calculate the average occurrence of accidents, I am 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
They are recorded occurrences per day and per hour, but the intention is to group for an interval of days and then average accidents for each interval.
It would help if you gave an example (5-10 lines) of your dataset, or some content from your source (maybe a csv)
– Miguel
I edited explaining the problem.
– Vinicius Oliveira