在 Pandas 中按小时过滤

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/20036953/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-13 21:21:22  来源:igfitidea点击:

Filter by hour in Pandas

pythonpandas

提问by em70

How can I filter a DataFrame indexed by datetime so that I get only the entries within certain hours of every day?

如何过滤按日期时间索引的 DataFrame 以便我只在每天的某些小时内获取条目?

I am looking for something equivalent to the following Rcode for an xtsobject

我正在寻找与以下R代码等效的xts对象

df["09:00:00::17:00:00"]

回答by Manre

Hope this helps: df[(df.Time > '08:00') & (df.Time < '08:05')]

希望这可以帮助: df[(df.Time > '08:00') & (df.Time < '08:05')]