2 回答
TA贡献1982条经验 获得超2个赞
.loc使用&的另一种方法shift
df.loc[(df['Minutes'] - df['Minutes'].shift(1)).ge(15),'Minutes'] = 15
print(df)
Dates Minutes
0 1/24/2020 2:58:04 PM 0
1 1/24/2020 3:13:04 PM 0
2 1/27/2020 10:04:09 AM 3
3 1/27/2020 10:19:09 AM 0
4 1/27/2020 10:34:09 AM 0
5 1/27/2020 10:49:10 AM 1
6 1/27/2020 11:04:09 AM 0
7 1/27/2020 11:19:09 AM 1
8 1/27/2020 11:34:09 AM 1
9 1/27/2020 11:49:09 AM 0
10 1/27/2020 12:04:09 PM 13
11 1/27/2020 12:19:09 PM 0
12 1/27/2020 12:34:09 PM 0
13 1/27/2020 12:49:09 PM 0
14 1/27/2020 1:04:09 PM 11
15 1/27/2020 1:19:09 PM 15
16 1/27/2020 1:34:09 PM 15
17 1/27/2020 1:49:09 PM 0
18 1/27/2020 2:04:09 PM 0
19 1/27/2020 2:19:09 PM 12
20 1/27/2020 2:34:09 PM 0
添加回答
举报