I have one data frame as below. At first,they have three columns('date','time','flag'). I want to add one column which based on the flag and date which means when I get flag=1 in one day at first, then this row target is 1, the other target in this day is 0.
date time flag target
0 2017/4/10 10:00:00 0 0
1 2017/4/10 11:00:00 1 1
2 2017/4/10 12:00:00 0 0
3 2017/4/10 13:00:00 0 0
4 2017/4/10 14:00:00 0 0
5 2017/4/11 10:00:00 1 1
6 2017/4/11 11:00:00 0 0
7 2017/4/11 12:00:00 1 0
8 2017/4/11 13:00:00 1 0
9 2017/4/11 14:00:00 0 0
10 2017/4/12 10:00:00 0 0
11 2017/4/12 11:00:00 0 0
12 2017/4/12 12:00:00 0 0
13 2017/4/12 13:00:00 0 0
14 2017/4/12 14:00:00 0 0
15 2017/4/13 10:00:00 0 0
16 2017/4/13 11:00:00 1 1
17 2017/4/13 12:00:00 0 0
18 2017/4/13 13:00:00 1 0
19 2017/4/13 14:00:00 0 0