How to calculate customer purchase interval and predict next purchase in python? Suppose we have a data set consists of columns


  TransactionId, CardNo, TransactionDate


then how can we calculate the customer purchase interval (means if customer A purchased on Jan 1st and after 10 days he again purchased, and then he again purchased after 15 days.) and how to predict the next visit of customer A by analysing the purchasing intervals of customer A.

Any help will be appreciated.
With Lifetimes it's very straight forward to implement.