I have a multiindex dataframe. Columns 'partner', 'employer', and 'date' are the multiindex. enter image description here
| partner | employer | date | ecom | sales | 
|---|---|---|---|---|
| A | a | 10/01/21 | 1 | 0 | 
| A | a | 10/02/21 | 1 | 0 | 
| A | a | 10/03/21 | 0 | 1 | 
| A | b | 10/01/21 | 0 | 1 | 
| A | b | 10/02/21 | 1 | 0 | 
| A | b | 10/03/21 | 1 | 0 | 
| B | c | 10/03/21 | 1 | 0 | 
| B | c | 10/04/21 | 1 | 0 | 
| B | c | 10/04/21 | 0 | 1 | 
I'm trying to find which unique (parter, employer) pairs have 'ecom' BEFORE 'sales'. For example, I want to have the output to be. How do I filter through each (partner, employer) pair with these conditions in python? enter image description here
| partner | employer | date | ecom | sales | 
|---|---|---|---|---|
| A | a | 10/01/21 | 1 | 0 | 
| A | a | 10/02/21 | 1 | 0 | 
| A | a | 10/03/21 | 0 | 1 | 
| B | c | 10/03/21 | 1 | 0 | 
| B | c | 10/04/21 | 1 | 0 | 
| B | c | 10/04/21 | 0 | 1 | 
 
     
    