【发布时间】:2022-11-23 16:07:44
【问题描述】:
现有数据框:
Id event time_spent_in_sec
A in 0
A step_1 2.2
A step_2 3
A done 3
B in 0
B step_1 5
B step_2 8
B step_3 15
B done 7
预期数据框:
Id event time_spent_in_sec
A in 2.2
A step_1 3
A step_2 3
A done 0
B in 5
B step_1 8
B step_2 15
B step_3 7
B done 0
我希望移动列中的值time_spent_in_sec并用 0 填充每个唯一 ID 的最后一行。
我尝试使用 shift(1) 但坚持用 0 填充最后一行
【问题讨论】: