Feb-21-2017, 10:24 AM
Dear Pandas Experts,
I signed up for an online training for python and one of the problems I have is that I got a series but should make a list out of it.
I need to create a list with the top 3 country names as shown. not their actual population.
I tried it with x.index[0] or x.[CTYNAME] but both do not work.
I would super appreciate any help how to extract this first "column" out of my series.
I signed up for an online training for python and one of the problems I have is that I got a series but should make a list out of it.
1 2 3 4 5 6 7 8 9 10 11 |
def answer_six(): statewiththemost = census_df.groupby([ 'CTYNAME' ]).CENSUS2010POP. sum ().nlargest( 3 ) x = statewiththemost return x #cal, tex, ny answer_six() CTYNAME California 37253956 Texas 25145561 New York 19378102 Name: CENSUS2010POP, dtype: int64 |
I tried it with x.index[0] or x.[CTYNAME] but both do not work.
I would super appreciate any help how to extract this first "column" out of my series.