I would like to use this dataframe
df = pd.DataFrame({'Serial' : ['A1', 'A1', 'A1', 'B1','B1', 'B1'],'Day' : ['01.01.2022', '01.01.2022', '01.01.2021', '01.01.2019', '01.01.2019', '01.01.2020'],'Else' : ['a', 'b', 'c', 'd','e', 'f']})
to groupby Serial and keep only rows with max(Day), ie here is my expected output:
| Serial | Day | Else |
|---|---|---|
| A1 | 01.01.2022 | a |
| A1 | 01.01.2022 | b |
| B1 | 01.01.2020 | f |
I success to compute the max but don't know how to use it to filter in order to get the expected output.
df['Day']= pd.to_datetime(df['Day'], format="%d.%m.%Y")
df = df.groupby(['Serial'])['Day'].max()