import pandas as pd
filepass = "C:/Users/aaaa/Desktop/USDJPY_M1/USDJPY_M1.csv"
date = pd.read_csv(filepass, sep=',',header=None,names=('day', 'open', 'high','low', 'close', 'volume'))
date['day'] = pd.to_datetime(date['day'],format='%Y.%m.%d %H:%M')#str to datetime64
df = date.set_index('day')
d_ohlc = {'open': 'first',
'high': 'max',
'low': 'min',
'close': 'last',
'volume': 'sum'}
day_df = df.resample('D').agg(d_ohlc)
day_df = day_df[day_df.index.weekday < 5]#mon==0,...,sun==6
参考:
https://note.nkmk.me/python-pandas-time-series-multiindex/
https://python.civic-apps.com/date-format/
https://note.nkmk.me/python-pandas-time-series-resample-asfreq/
https://note.nkmk.me/python-pandas-resampling-ohlc/