I have this dataframe where I have more than one column and I want to know additional data to the maximum value of one column
For example, given the following code, show the country where the number is the highest per year per causes What I did was:
var=data.groupby(["Year","Causes"])["number"].max()
But this only shows the max value for each of the years and each of the causes. I would like to know which country is the one associated with the max value from the number.
- This code shows the highest number per cause per year, but I need to show the country associated with the highest number per cause per year
I tried using idxmax() instead of max() but it did not work