Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Assignment 2, Q6, your result is not correct I think... #3

Open
OwenZzzz opened this issue Feb 4, 2020 · 1 comment
Open

Assignment 2, Q6, your result is not correct I think... #3

OwenZzzz opened this issue Feb 4, 2020 · 1 comment

Comments

@OwenZzzz
Copy link

OwenZzzz commented Feb 4, 2020

My result is ['California', 'Texas', 'Illinois'], after doublecheck I suppose its the right answer.
Basically the ranking didn't operate correctly in your code I think.

And my code below for your reference

def answer_six():

x = census_df[census_df['SUMLEV'] == 50]
x['sort_result'] = x['CENSUS2010POP'].groupby(x['STNAME']).rank(ascending = False)
max_3 = x[x['sort_result']<=3]
summed_max_3 = max_3.groupby(max_3['STNAME'])['CENSUS2010POP'].sum().sort_values(ascending = False)

return list(summed_max_3.index[:3].values)

answer_six()

@jjdixon
Copy link

jjdixon commented May 11, 2020

I wrote this one up too. I got the same answer as you for what its worth.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants