df = pd.DataFrame({"Date":['7.6.2021','7.6.2021','7.6.2021','8.6.2021','8.6.2021','8.6.2021','9.6.2021','9.6.2021','9.6.2021','10.6.2021','10.6.2021','10.6.2021'],
"WH": ['k','a','b','k','k','a','k','b','c','b','k','k']})
A running count based on the value of column "WH", in that a value of "k' is counted as a running total until the date changes. Thereafter count goes to 0 and the process repeats as the date changes.
Desired output:
Date WH count
0 7.6.2021 k 1
1 7.6.2021 a 1
2 7.6.2021 b 1
3 8.6.2021 k 1
4 8.6.2021 k 2
5 8.6.2021 a 2
6 9.6.2021 k 1
7 9.6.2021 b 1
8 9.6.2021 c 1
9 10.6.2021 b 0
10 10.6.2021 k 1
11 10.6.2021 k 2