I have a dataframe as defined below (df) with daily frequency and I would like to convert this to minute frequency, starting at 8:30 and ending at 16:00.
import
I believe you need reshape by DataFrame.unstack for DatetimeIndex
, then set minute frequency by DataFrame.asfreq, filter times by DataFrame.between_time and last use DataFrame.stack for MultiIndex
:
df1 = df.unstack().asfreq('Min', method='ffill').between_time('8:30','16:00').stack()
print (df1.head(10))
returns
date ticker
2016-11-28 08:30:00 aapl 0.2
amzn 0.2
fb 0.2
ge 0.2
jpm 0.2
msft 0.2
2016-11-28 08:31:00 aapl 0.2
amzn 0.2
fb 0.2
ge 0.2