按时间索引过滤Pandas DataFrame [英] Filter Pandas DataFrame by time index

查看:131
本文介绍了按时间索引过滤Pandas DataFrame的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个从6:36 AM到5:31 PM的pandas DataFrame.我想删除时间少于8:00:00的所有观察结果.这是我的尝试:

I have a pandas DataFrame from 6:36 AM to 5:31 PM. I want to remove all observations where the time is less than 8:00:00 AM. Here is my attempt:

df = df[df.index < '2013-10-16 08:00:00']

这什么都不做,请帮忙.

This does nothing, please help.

推荐答案

您要df.loc[df.index < '2013-10-16 08:00:00'],因为您是按标签(索引)而不是值进行选择.

You want df.loc[df.index < '2013-10-16 08:00:00'] since you're selecting by label (index) and not by value.

按标签选择

这篇关于按时间索引过滤Pandas DataFrame的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆