Reputation: 780
Helo everyone,
I'm trying to find the average of my powerAC
dataframe (5min interval) for each day, so I have 1 year of data and for the whole period I would like to know what was the average value at 09:05, 09:10, 09:15, for example, and so on. Here is an example:
And I would like my output to be as follows:
The closer I got to what I want was:
minute = pd.to_timedelta(powerAC.index.minute, unit='m')
powerAC.astype(float).groupby(minute).mean()
tried with powerAC.index.hour
also but still doesn't provide me with my desired output. I saw many solution in here but they were all with hourly average or 5 minute average using .resample
. Any help is really appreciated!
Upvotes: 0
Views: 264
Reputation: 150805
You can do:
hhmm = pd.to_datetime(powerAC.index).strftime('%H:%M')
powerAC.astype(float).groupby(hhmm).mean()
If you want timedelta, you can do:
datetime = pd.to_datetime(powerAC.index)
hhmm = datetime - datetime.floor('D')
powerAC.astype(float).groupby(hhmm).mean()
Upvotes: 1