pk_cid means client id Each pk_partition represents the current state of the month of em_acount(which is a product sold). So if a client has 1 in january and also has 1 in February that means that he had only buy once in January. I would like to change the rest of the months to have a 0 if the previous month has a 1 to see exacly the time where people buy only keeping the first one.
if its possible on the other hand if a person left to have a -1
you can create a pandas.Series:
a = pd.Series({(15891, '2018-07-28'): 1,
(15891, '2018-08-28'): 0,
(16063, '2018-11-28'): 0,
(16063, '2018-12-28'): 0,
(16063, '2019-01-28'): 0,
(16063, '2019-02-28'): 0,
(16063, '2019-03-28'): 0,
(16063, '2019-04-28'): 0,
(16063, '2019-05-28'): 0,
(16203, '2018-12-28'): 0,
(16203, '2019-01-28'): 1,
(16203, '2019-02-28'): 1,
(16203, '2019-03-28'): 1,
(16203, '2019-04-28'): 1,
(16203, '2019-05-28'): 1,
(16502, '2018-09-28'): 0,
(16502, '2018-10-28'): 1,
(16502, '2018-11-28'): 1,
(16502, '2018-12-28'): 1,
(16502, '2019-01-28'): 1})
Desired output
Thanks