I want to groupby multiple column based on a particular column in python. When doing so, for a particular column I want the value to last but one row'th value. If I wanted the same for all column, I would've have used nth method. but I want it for a particular column and I couldn't find the solution online. How can I do this?
Aggregated_Halt = df.groupby('Group_Halt').agg({'Date_Time': [**last but one row**], 'Latitude': ['last'],'Longitude': ['last'], 'Time_diff':'sum', 'LocationAddress': 'last'})
Here I want datetime column to have last but one row value.