I have pandas Dataframe with datetime index like 'YYYY-MM-DD HH:MM:SS'.
Index Parameter
2007-05-02 14:14:08 134.8
2007-05-02 14:14:32 134.8
2007-05-02 14:14:41 134.8
2007-05-02 14:14:53 134.8
2007-05-02 14:15:01 134.8
2007-05-02 14:15:09 134.8
......
2007-05-30 23:08:02 105.9
2007-05-30 23:18:02 105.9
2007-05-30 23:28:02 105.9
2007-05-30 23:38:03 105.8
It is possible to get slice a DataFrame by year df['2007']
or by month df['2007-05']
?
But when I've tried to slice DataFrame by day, for example df['2007-05-02']
, I've got the error:
KeyError: < Timestamp: 2007-02-05 00:00:00.
I use the pandas version 8.0.1. Is it possible to slice DataFrame with smaller frequency than year or month? For example, by day or hour?
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…