I am trying to subset a pandas time series that spans multiple days by time of day. E.g., I only want times between 12:00 and 13:00.
I know how to do this for a spec
Assuming the index is a valid pandas timestamp, the following will work:
test.index.hour
returns an array containing the hours for each row in your dataframe. Ex:
df = pd.DataFrame(randn(100000,1),columns=['A'],index=pd.date_range('20130101',periods=100000,freq='T'))
df.index.year
returns array([2013, 2013, 2013, ..., 2013, 2013, 2013])
To grab all rows where the time is between 12 and 1, use
df.between_time('12:00','13:00')
This will grab that timeframe over several days/years etc. If the index is not a valid timestamp, convert it to a valid timestamp using pd.to_datetime()