Create the output dataframe from input, how to filter for rows when target == 1 for the first time for each id, or in order words removing consecutive occurrence for each ids where target is 1 however keep all 0s in target before target = 1.
Input
ID date target
a1 2019-11-01 0
a1 2019-12-01 0
a1 2020-01-01 1
a1 2020-02-01 1
a1 2020-03-01 0
a2 2019-11-01 0
a2 2019-12-01 1
a2 2020-03-01 0
a2 2020-04-01 1
Output
ID date target
a1 2019-11-01 0
a1 2019-12-01 0
a1 2020-01-01 1
a2 2019-11-01 0
a2 2019-12-01 1