How do you iterate through a pandas DataFrame based on the hour? Let's say we want to iterate only through the rows corresponding to the 10:00 hours; I've been using the "between_time()" method but is not enough flexible when using it with list comprehensions. What is the best approach for this?
Value
Time
2018-11-09 10:00:00 3386.0
2018-11-09 11:00:00 2477.0
2018-11-09 12:00:00 2110.0
2018-11-09 13:00:00 4337.0
2018-11-12 10:00:00 3023.0
2018-11-12 11:00:00 2307.0
2018-11-12 12:00:00 1824.0
df.index = pd.to_datetime(df.index)
thendf.loc[df.index.hour == 10]
df
.