【发布时间】:2020-09-03 19:54:48
【问题描述】:
我正在尝试实现一个条件,如果不正确值的计数大于 2(在下面的示例中为 2019-05-17 和 2019-05-20),那么完整日期(所有时间块)为删除
输入
t_value C/IC
2019-05-17 00:00:00 0 incorrect
2019-05-17 01:00:00 0 incorrect
2019-05-17 02:00:00 0 incorrect
2019-05-17 03:00:00 4 correct
2019-05-17 04:00:00 5 correct
2019-05-18 01:00:00 0 incorrect
2019-05-18 02:00:00 6 correct
2019-05-18 03:00:00 7 correct
2019-05-19 04:00:00 0 incorrect
2019-05-19 09:00:00 0 incorrect
2019-05-19 11:00:00 8 correct
2019-05-20 07:00:00 2 correct
2019-05-20 08:00:00 0 incorrect
2019-05-20 09:00:00 0 incorrect
2019-05-20 07:00:00 0 incorrect
期望的输出
t_value C/IC
2019-05-18 01:00:00 0 incorrect
2019-05-18 02:00:00 6 correct
2019-05-18 03:00:00 7 correct
2019-05-19 04:00:00 0 incorrect
2019-05-19 09:00:00 0 incorrect
2019-05-19 11:00:00 8 correct
我不确定要执行哪个基于时间的操作才能获得所需的结果。谢谢
【问题讨论】:
-
似乎您只需要日期时间在
2019-05-17 04:00:00和2019-05-19 11:00:00之间的记录。 Pandas.Timestamp() 允许您通过简单的 >、 -
是的,在这个例子中。但总的来说,我关心的是删除不正确值的相应计数大于 2 的日期。
标签: python dataframe time time-series conditional-statements