Hello I have an hourly timeseries that I would like to mask if the timeseries index is outside business hours.
I can achieve what I want for business day data but not hourly data
import datetime
import pandas as pd
import numpy as np
from pandas.tseries.offsets import *
st = datetime.datetime(2013, 1, 1)
ed = datetime.datetime(2013, 2, 1)
myrange = pd.date_range(st, ed, freq='H')
ts = pd.Series(np.random.randn(len(myrange)), index=myrange)
ts.asfreq(BDay()).asfreq(Day())
I have tried generating a BDay date range and then changing the freq to hourly but this doesn't work.
newrange = pd.date_range(datetime.datetime(2013, 1, 1), datetime.datetime(2013, 1, 1), freq='B')
#but adding this doesn't work .asfreq(Hour())
ts[ts.index.isin(newrange)].asfreq(Hour()) #Of course this only gives one value on the day
Thanks