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()