Tell us what’s happening:
I managed to find the highest % of high earners for each country. However, I managed to do it in three lines of code (code below) instead of two lines.
Can someone provide me with some guidance in terms of how I can get the result in two lines of code?
Your code so far
highest_earning_country = df[df[“salary”]==">50K"].groupby([“native-country”]).size()/df.groupby([“native-country”])[“salary”].size()
highest = highest_earning_country.reset_index(name= “% of high earner”)
maxincome = highest[highest["% of high earner"]== max(highest["% of high earner"])]
Your browser information:
User Agent is:
Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/101.0.4951.54 Safari/537.36
Challenge: Demographic Data Analyzer
Link to the challenge: