How to create new time entries in a pandas dataframe by linear interpolating

I have a Pandas dataframe in hourly resolution as you can see in the screenshotenter image description here

So I have a temperature value for each hour of the day. Now I would like to increase the temporal resolution and have entries for every 15 minutes (00:00, 00:15, 00:30, 00:45, 01:00, 01:15 etc.). And for each of the new entries the values of the temperatures should be linearly interpolated.

Can you tell me, how I can do this by using pandas? I’d appreciate every comment.

Answer

IIUC, here’s one way:

df['Time (UTC)'] = pd.to_datetime(df['Time (UTC)'], format = '%d.%m.%Y %H:%M')
df1 = df.set_index('Time (UTC)').asfreq('15T')
df1.Temperature = df1.Temperature.interpolate()