Quartiles, Quantiles, and Interquartile Range

In step 8 of the Life Expectancy By Country project ( Quartiles, Quantiles, and Interquartile Range) it was required to copy and paste the following code:


but there is an error (ValueError: Lengths must match to compare)
so I change my code into
but still got an error AttributeError: ("‘Series’ object has no attribute ‘GDP’", ‘occurred at index Country’)
Can anyone help me with this? I got stuck in this step for many hours :frowning:

1 Like

Can you post a link to the exercise?

2 Likes

https://www.codecademy.com/paths/analyze-data-with-python/tracks/ida-6-statistics-for-data-analysis/modules/ida-6-2-quartiles-quantiles/projects/life-expectancy-by-country

The first block you posted looks correct.

Here’s what I have, and it works:

low_gdp = data[data['GDP'] <= median_gdp]

Did everything prior work as expected? Can you post your earlier code using the </> for preformatted text?

I also get the valueerror and I don’t know how to fix it. Please help.

I removed the square brackets around .5 and now it works. Idk why…