I have a dataframe:
install type id date
2021-11-01 main a1 NA
2021-11-01 main a2 2021-11-02
2021-11-01 main a3 2021-11-02
2021-11-01 main a3 2021-11-02
2021-11-02 down b4 2021-11-05
2021-11-03 main b7 2021-11-05
2021-11-04 main a3 2021-11-05
I want to group this data by date and type and count unique id's with same type which have install lower than date. So desired result is:
date type count
2021-11-02 main 3
2021-11-05 down 1
2021-11-05 main 4
For 2021-11-02 main its 3 because there are 3 unique id's with same type and lower date (a1, a2, a3), for 2021-11-05 down its only b4, for 2021-11-05 main its a1, b7, a2, a3
How to do that? I know about groupby and nunique(), but I dint know how to write condition of install being lower than date.
P.S.
I need it to calculate retention value for each date and type group