I have a dataframe df
date close
0 2006-01-02 143.2
1 2006-01-07 165.2
2 2008-09-19 198.0
3 2008-12-20 198.0
I want to groupby year and find the maximum close such that duplicates are kept.
So far what I have is
df.groupby(df.date.dt.year).max()[["close"]]
date close
date
2006 2006-01-07 165.2
2008 2008-12-20 198.0
whereas what I want is the two close
values in 2008 since they are identical
date close
date
2006 2006-01-07 165.2
2008 2008-09-19 198.0
2008 2008-12-20 198.0
How do I do this?