Home > Back-end >  How do I make 2 hour windows using data thats all 1 hour windows
How do I make 2 hour windows using data thats all 1 hour windows

Time:12-01

I have data that looks like this:

Datetime Price

g

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()
  • Related