mirror of
https://github.com/webclinic017/drift.git
synced 2026-07-29 03:37:45 +00:00
b656f790f5
* feat(Data): resample exogenous/other datasource when their frequency is different * fix(Linter): ran * fix(Data): resampling done properly
17 lines
450 B
Python
17 lines
450 B
Python
import pandas as pd
|
|
|
|
|
|
def resample_ohlc(df, period):
|
|
output = pd.DataFrame()
|
|
period = period.replace("m", "T")
|
|
|
|
if "open" in df.columns:
|
|
output["open"] = df.open.resample(period).first()
|
|
output["high"] = df.high.resample(period).max()
|
|
output["low"] = df.low.resample(period).min()
|
|
output["close"] = df.close.resample(period).last()
|
|
else:
|
|
output = df.resample(period).ffill()
|
|
|
|
return output
|