I want to get the maximum value for a column for each unique value in another column and grouped by another column.
Say I have the following:
Ticker,Bid,Year
ROG SW,8.0,19
ROG SW,9.0,20
ROG SW,9.5,20
NOVN SW,2.0,19
NESN SW,3.0,19
DAI GR,2.5,20
DAI GR,3.0,19
DAI GR,4.0,19
I would like this to then be:
Ticker,Bid,Year
ROG SW,8.0,19
ROG SW,9.5,20
NOVN SW,2.0,19
NESN SW,3.0,19
DAI GR,2.5,20
DAI GR,4.0,19
So the maximum bid for each year for each ticker.
I know I can use:
df.groupby(['Ticker'], sort=False)['Bid'].max()
but I need to do this for each unique year. Thanks
Try:
Output: