Hi I have a data frame that looks like this. Based on the same datetime, I need to keep the last row as 1 and replace the remaining ones as 0. Is there anyway for me to do this?
DateTimeStarted Value
0 2020-12-19 16:00:00 1
1 2020-12-19 16:00:00 1
2 2020-12-19 16:00:00 1
3 2020-12-19 16:00:00 1
4 2020-12-19 16:00:00 1
5 2020-12-19 16:00:00 1
6 2020-12-19 16:00:00 1
7 2020-12-19 16:00:00 1
8 2020-12-19 16:00:00 1
9 2020-12-19 16:00:00 1
10 2020-12-19 16:00:00 1
11 2020-12-19 16:00:00 1
12 2020-12-19 16:00:00 1
13 2020-12-19 16:00:00 1
14 2020-12-19 16:00:00 1
15 2020-12-19 16:00:00 1
16 2020-12-19 16:00:00 1
17 2020-12-19 16:00:00 1
18 2020-12-19 16:00:00 1
19 2020-12-26 18:00:00 1
20 2020-12-26 18:00:00 1
21 2020-12-27 13:00:00 0
22 2020-12-27 14:00:00 0
23 2020-12-27 15:00:00 0
24 2020-12-27 15:00:00 0
25 2020-12-27 17:00:00 0
The solution should look like this. The values 0 should also remained unchanged.
DateTimeStarted Value
0 2020-12-19 16:00:00 0
1 2020-12-19 16:00:00 0
2 2020-12-19 16:00:00 0
3 2020-12-19 16:00:00 0
4 2020-12-19 16:00:00 0
5 2020-12-19 16:00:00 0
6 2020-12-19 16:00:00 0
7 2020-12-19 16:00:00 0
8 2020-12-19 16:00:00 0
9 2020-12-19 16:00:00 0
10 2020-12-19 16:00:00 0
11 2020-12-19 16:00:00 0
12 2020-12-19 16:00:00 0
13 2020-12-19 16:00:00 0
14 2020-12-19 16:00:00 0
15 2020-12-19 16:00:00 0
16 2020-12-19 16:00:00 0
17 2020-12-19 16:00:00 0
18 2020-12-19 16:00:00 1
19 2020-12-26 18:00:00 0
20 2020-12-26 18:00:00 1
21 2020-12-27 13:00:00 0
22 2020-12-27 14:00:00 0
23 2020-12-27 15:00:00 0
24 2020-12-27 15:00:00 0
25 2020-12-27 17:00:00 0