Skip to content
Advertisement

How to get the last/maximum date that is on/earlier than another baseline date by user?

I have a df where I am trying to create the Last Login Date column, as shown in the image.

I am not sure how to get the maximum login date that was on/prior the email notification date for that current row. I added explanations on how I expect the data to look. Any help is appreciated in either sql or pandas.

enter image description here

Advertisement

Answer

Use pandas.merge_asof:

output:

User contributions licensed under: CC BY-SA
7 People found this is helpful
Advertisement