Demographic Data Analyzer: Highest Earning Country

Having issues with this, and I’ve spent way too much time on it. Would like to move on with my life. Here is what I have so far, any help would be appreciated:

Don’t waste any more time on it, simply put it aside and move on with your life. Unless your life depends on finishing this code… :smiley:

What are the issues? Wrong country, wrong percentage? What are your results? What do you think goes wrong?

It’s definitly not the easiest line of code to get that result.
If you just can’t get your brain around it, use the search function and you will find a couple of topics to the challenge which may or may not include working code.

While not the to-go strategy to solve this, it’s the most reliable to “move on” ^^


I made another dataframe countries with the ['native-country'].value_counts() of all records and of the records with salary > 50k.
The new dataframe gets indexed by country name because both the series are outputs of the same value_counts().
Added new column with the percentage for each country…

The function pandas.DataFrame.idxmax() helped with the rest

Hope that helps!

This topic was automatically closed 182 days after the last reply. New replies are no longer allowed.