我有一个数据框,
Check In Date Check Out Date Number stage
2020/5/22 16:23 2020/5/22 18:39 1 a
2020/5/22 22:41 2020/5/23 2:03 1 b
2020/5/23 2:04 2020/5/23 2:04 1 c
2020/5/23 2:04 2020/5/23 2:56 1 d
2020/5/23 2:56 2020/5/23 2:56 2 a
2020/5/24 8:39 2020/5/24 8:39 2 b
2020/5/24 8:40 2020/5/24 10:58 2 c
2020/5/24 10:59 2020/5/24 10:59 2 d
df = pd.DataFrame({'Check In Date': ['2020/5/22 16:23', '2020/5/22 22:41', '2020/5/23 2:04', '2020/5/23 2:04', '2020/5/23 2:56', '2020/5/24 8:39', '2020/5/24 8:40', '2020/5/24 10:59'],
'Check Out Date': ['2020/5/22 18:39', '2020/5/23 2:03', '2020/5/23 2:04', '2020/5/23 2:56', '2020/5/23 2:56', '2020/5/24 8:39', '2020/5/24 10:58', '2020/5/24 10:59'],
'Number': [1, 1, 1, 1, 2, 2, 2, 2],
'stage': ['a', 'b', 'c', 'd', 'a', 'b', 'c', 'd']})
我正在尝试在数据框中进行一些计算,如下所示:
1 2
a -> b 4:02:00 5:43:00
b -> c 0:01:00 0:01:00
c -> d 0:00:00 0:01:00
等于
1 2
a -> b b: ckeck in date - a: check out date b: ckeck in date - a: check out date
b -> c c: ckeck in date - b: check out date c: ckeck in date - b: check out date
c -> d d: ckeck in date - c: check out date d: ckeck in date - c: check out date
我检查了与熊猫和数据框相关的示例,但我仍然不知道如何实现这一点。任何想法?
天涯尽头无女友
相关分类