如何仅在日期时间戳为00:00:00时进行正向填充?
每 date
有一个 00:00:00
由于传感器工作不正常,将出现空值。其他时候会有空的,他们需要保留。
+---+-------------------+-----+
| id| date|value|
+---+-------------------+-----+
| A1|2016-09-30 23:00:00| 3|
| A1|2016-10-01 00:00:00| Null|
| A1|2016-10-01 01:00:00| 1|
| A1|2016-10-01 02:30:30| 3|
| A9|2016-10-05 23:00:00| 3|
| A9|2016-10-06 00:00:00| Null|
| A9|2016-10-06 02:20:00| 4|
| A9|2016-10-06 03:20:00| Null|
+---+-------------------+-----+
所需Dataframe:
+---+-------------------+-----+
| id| date|value|
+---+-------------------+-----+
| A1|2016-09-30 23:00:00| 3|
| A1|2016-10-01 00:00:00| 3|
| A1|2016-10-01 01:00:00| 1|
| A1|2016-10-01 02:30:30| 3|
| A9|2016-10-05 23:00:00| 3|
| A9|2016-10-06 00:00:00| 3|
| A9|2016-10-06 02:20:00| 4|
| A9|2016-10-06 03:20:00| Null|
+---+-------------------+-----+
1条答案
按热度按时间pes8fvy91#
你可以用
lag
功能: