Skip to content

Instantly share code, notes, and snippets.

@SathishN
Created August 6, 2021 02:18
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save SathishN/68287997d35fd813ad2e54f7f5dcd562 to your computer and use it in GitHub Desktop.
Save SathishN/68287997d35fd813ad2e54f7f5dcd562 to your computer and use it in GitHub Desktop.
def resample(df, interval='5min'):
df_s = df.copy()
df_r = df_s.resample(interval, label='right', closed='right') \
.agg({'Open': 'first',
'High': 'max',
'Low': 'min',
'Close': 'last',
'Volume': 'sum',
'OI': 'last'}).dropna()
# print(df_r.to_string())
return df_r.copy()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment