FAQ: Introduction to Statistics with NumPy - Percentiles, Part I

This community-built FAQ covers the “Percentiles, Part I” exercise from the lesson “Introduction to Statistics with NumPy”.

Paths and Courses
This exercise can be found in the following Codecademy content:

Data Science

Introduction to Statistics with NumPy

FAQs on the exercise Percentiles, Part I

Join the Discussion. Help a fellow learner on their journey.

Ask or answer a question about this exercise by clicking reply (reply) below!

Agree with a comment or answer? Like (like) to up-vote the contribution!

Need broader help or resources? Head here.

Looking for motivation to keep learning? Join our wider discussions.

Learn more about how to use this guide.

Found a bug? Report it!

Have a question about your account or billing? Reach out to our customer support team!

None of the above? Find out where to ask other questions here!

What is the difference between the percentage and percentile?
I can’t get clear

I noticed the array was not sorted before I ran np.percentile. Does np.percentile sort the list for you?

2 Likes

i also have the same question

Maybe a little late, but yes, it does.

You can check it out by sorting your array:

patrons = np.array([ 2, 6, 14, 4, 3, 9, 1, 11, 4, 2, 8])

patrons_ordered = np.sort(patrons)
print(patrons_ordered)

thirtieth_percentile = np.percentile(patrons, 30)
print(thirtieth_percentile)

seventieth_percentile = np.percentile(patrons, 70)
print(seventieth_percentile)

The output would be this:

[ 1 2 2 3 4 4 6 8 9 11 14]
3.0 <-- 30th percentile
8.0 <-- 70th percentile

Cheers! :beer:

1 Like

what if the array has even instead of odd numbers? what then is the calculation behind the number generated for the 30th and 70th percentile? TIA!