For each user_id, find the difference between the last action and the second last action. Action here is defined as visiting a page. If the user has just one action, you can either remove her from the final results or keep that user_id and have NULL as time difference between the two actions.

The table below shows for each user all the pages she visited and the corresponding timestamp.


You can download the data set here.

Column Name Value Description
user_id 6684 this is id of the user
page home_page the page visited
unix_timestamp 1451640067 unix timestamp in seconds


Full course in Product Data Science