I have data that looks like this:
Datetime Price
and was just wondering how about I would turn them into 2 hour windows instead and use the average of the price of the two
CodePudding user response:
Let us do resample
with 2h
freq
df['Datetime'] = pd.to_datetime(df['Datetime'], dayfirst=True)
df.resample('2h', on='Datetime', origin='start')['Price'].mean()