Demographic-data-analyzer higher_education_rich

Hi,
I’m stuck on this part of the Data Analysis with Python Projects assignment :

higher_education = ((df.education == 'Bachelors') | (df.education == 'Masters') | (df.education == 'Doctorate'))
 
   lower_education = ((df.education != 'Bachelors') & (df.education != 'Masters') & (df.education != 'Doctorate'))

   # percentage with salary >50K
   higher_education_rich = ((higher_education[(higher_education.salary == '>50K')]) / len(higher_education) * 100).round(1)
   lower_education_rich = (((lower_education) & (lower_education.salary == '>50K')) / len(lower_education) * 100).round(1)

The console returns : AttributeError: 'Series' object has no attribute 'salary'

I wrap my head around it but I can’t find a solution.

Print out higher_education and lower_education and see what they are

They’re series but I don’t understand why, and converting them back to frame isn’t working with the follow up code.

I fixed it with just a count method applied to the resulting series :slight_smile:

    # percentage with salary >50K
    higher_education_rich = ((higher_education[(df.salary == '>50K')]).count() / len(higher_education) * 100).round(1)
    lower_education_rich = ((lower_education[(df.salary == '>50K')]).count() / len(lower_education) * 100).round(1)

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