Calculate average of intraday cumulative volume by time of day.
import pandas as pd
def cumulative_intraday_volume(volume_series):
"""Calculate the average of intraday cumulative volume by time of day.
Params
------
volume_series: pd.Series
Returns
-------
volume_cum_daily: pd.Series
Average Cumulative Volume grouped by time of day.
"""
volume_cum_daily = volume_series.groupby(volume_series.index.date).cumsum(axis=0)
volume_cum_daily.index = volume_series.index.tz_convert('US/Eastern')
return volume_cum_daily