Find the time between two events by customer id I need to find a customer has bought P1, and after how many days customer will buy P2. 
I am unable to find the days between order of P1 and the next order of P2 by the same customer.

I have data as shown below. 

Customer ID   Order_Date   Product  
       C-87   11/20/2018        P2  
       C-87    7/25/2018        P1  
       C-87    7/19/2019        P1      
       C-87     8/2/2018        P2  
       C-87    12/9/2019        P1  
        ...          ...       ...
       C-22    9/22/2018        P2  
       C-22     9/4/2018        P2  
       C-22    1/15/2018        P1  
       C-22     9/5/2019        P2  
       C-22    3/20/2018        P1
You can split it into two dataframe containing only one of P1 and P2 first.

df1 = df[df.index[df['Product'] == 'P1'].tolist()]
df2 = df[df.index[df['Product'] == 'P2'].tolist()]


And then marge df1 and df2 on Customer ID and Product

df1.merge(df2, 'inner', left_on=['Customer ID', 'Product'], right_on=['Customer ID', 'Product'], copy=False)