How are you? How can I take the last row per user in a data frame (each user has many services, the dataframe is biger but i gonna do a small example) example:
pd.DataFrame({"user":['1','1','1','1','1','2','2','3','4'],
"service":['a','b','nan','c','b','a','c','a','a'],
"date":['2020-01-13','2020-01-17','2020-02-18','2020-02-18','2020-03-22','2020-01-13','2020-02-13','2020-01-13','nan']})
I only want the last row per user (because it is the near date), my idea in the future is to create a new column name "service history" and put the array there ... but the first one I only need to take the last raw per user , as below output:
pd.DataFrame({"user":['1','2','3','4'],
"service":['b','c','a','a'],
"date":['2020-03-22','2020-02-13','2020-01-13','nan']})