I already asked a related question filling gaps in time series
Fill Gaps in time series pandas dataframe
and Akshay Sehgal was kind enough to give a good a detailed answer!
However I found another problem with my data.
Tha following code now works fine in filling the gaps as long as there a time stamps for the beginning and ending of a trading day.
For example I want to fill all gaps in the timeseries between 09:30 and 16:00. As long as there is a timestamp in the data starting at 09:30 and ending at 16:00 all the gaps within this time are filled by resample().
However if the data for the current day starts at 9:45 the resample function will start filling the gaps from this time onwards.
But it will not generate new timestamps from 09:30 to 09:40 (If we consider a 5 Minute intervall)
This is the code I currently use:
# create new col FillDate from the timestamp (we need this to group the data (otherwise resample would also create new dats and not only times))
df_process['FillDate'] = df_process['Exchange DateTime'].dt.date
# set timestamp as index
df_process.set_index('Exchange DateTime', inplace=True)
# group by for each date, resample missing timestamps and forward fill values
df_process = df_process.groupby('FillDate').resample(rule=update_interval).ffill()
# reset the index and delete the colume Fill Date
df_process_out = df_process.reset_index('FillDate', drop=True).drop('FillDate',1)
However I would like to resample always in the fixed time intervall 09:30 to 16:00 regardless if there is a timestamp available at 09:30 or 16:00.
Any ideas how I can solve this in an efficient way?
Any help/guidance would be highly appreciated Thanks