I am trying to convert a series of Dates to a series of Date Intervals but cannot figure out how to do it in one beautiful query. I would like it to operate in the same way that the .diff() method operates. See the image of the behavior I am expecting.
I have nearly extracted the information I am looking for with this like code:
dates = {}
for key,item in app.sort_values('Date').groupby('UniqueId'):
x = list(item.Date)
date_range = []
for k in range(0,len(x)-1):
date_range.append([x[k],x[k+1]])
dates.update({key:date_range})
Any Direction Helps. Thanks!