0

I have data (DateTime stamp) and corresponded value. The Date field which has a series of picked dates formatted as (dd/mm/yyyy hh:mm: ss) some rows have 3 values or more. Is there any way in python to take the average of the values at the same hour and save it in one row with the hour hh:00:00.

Example
01/01/2019 01:13       35 **
01/01/2019 01:38       37 **
01/01/2019 02:03       45 **
01/01/2019 02:15       46 **
01/01/2019 02:40       55 **

and need to be like :

01/01/2019 01:00       36 **
01/02/2019 02:00       50

Thanks

ilias-sp
  • 6,135
  • 4
  • 28
  • 41
S.Ozan
  • 51
  • 6
  • 1
    Does this answer your question? [averaging every five minutes data as one datapoint in pandas dataframe](https://stackoverflow.com/questions/20048200/averaging-every-five-minutes-data-as-one-datapoint-in-pandas-dataframe) – FObersteiner Jul 20 '20 at 13:19
  • Thanks, yes it looks useful with doing some modification. Thanks – S.Ozan Jul 20 '20 at 15:08
  • 1
    if you want a rolling mean instead, you could also have a look at this: https://stackoverflow.com/q/49087038/10197418 – FObersteiner Jul 20 '20 at 15:10
  • This answered as following:- df.set_index('Date').Count.resample('H').mean() – S.Ozan Jul 20 '20 at 22:32

1 Answers1

0

This answered as following:-

df.set_index('Date').Count.resample('H').mean()

S.Ozan
  • 51
  • 6