Q:

Sum and average after datetime pandas

I have a problem trying to make a sum after the date within an hour and the average from column no. 2 and also after the date within an hour. I tried something like this, but there are errors.
df[6] = df.groupby(df[5].dt.hour).sum() 
df

I know how to do the whole column, but I do not know how the average is in an hour. He would like to get such an effect:
     2   3   4   5                         Sum        Average
0   29  12  296 2017-01-01 01:00:07.500     4           47,7
1   29  12  296 2017-01-01 01:00:07.500     4           47,7
2   66  5   646 2017-01-01 01:00:31.410     4           47,7  
3   66  5   646 2017-01-01 01:00:31.410     4           47,7  
4   63  5   596 2017-01-01 02:00:32.670     2            63
5   63  5   596 2017-01-01 02:00:32.670     2            63
6   43  8   655 2017-01-01 03:00:36.720     2            43 
7   43  8   655 2017-01-01 03:00:36.720     2            43

A:

You can use:
 df['Avg'] = df.groupby(pd.Grouper(key=5, freq='H'))[2].transform('mean')

