df['rolling_sum_by_time'] = df.groupby(df.index.time)['X'].apply(lambda x:
    x.shift(1).rolling(10).sum())
Pandas: how to compute the rolling sum of a variable over the last few days but only at a given hour?