Percentiles: Analyzing Data with NumPy

Use NumPy's percentile method to calculate the percentage of data values below a given number in a dataset.

Gain clarity on percentiles and their practical significance in data analysis. Learn how NumPy simplifies percentile calculations to efficiently interpret data distributions.

Key Insights

  • Percentile indicates the percentage of values in a dataset that fall below a certain value, making it a useful measure for understanding data distribution.
  • NumPy provides a straightforward method for calculating percentiles: the percentile method, which easily computes percentile values from a set of numerical data.
  • The example demonstrates the calculation of the 75th and 25th percentiles, which indicate that 75% of the sample degrees are below 90.5 and 25% are below 71.

This lesson is a preview from our Data Science & AI Certificate Online (includes software) and Python Certification Online (includes software & exam). Enroll in a course for detailed lessons, live instructor support, and project-based training.

Let's talk about percentile. Percentile is a fairly simple measurement. It's the percent of values in a collection that are lower than a given number.

If we want to calculate, give me the number below which 75% of degrees fall. NumPy has our back on this. NumPy has a percentile method.

Then, you pass the list you want it to analyze and specify a percentile number. Let's set that to a variable: percentile_75.

That makes sense to me. And print it. I run that, and it's 90.5. So, that means in our degrees—let's just take a look at our degrees again—

We can remember what these values are. Okay, 75% of them are below 90.5, so 90 or lower.

There we go. So 25% of them are above there. Now, how about the 25th percentile—the value below which 25% of the data falls?

We can take a look at the same measurement with degrees and 25. Percentiles are very useful when you're trying to understand a dataset. What is the general distribution of it? So, 71 means 25% are below that value, and 75% are above it.

photo of Colin Jaffe

Colin Jaffe

Colin Jaffe is a programmer, writer, and teacher with a passion for creative code, customizable computing environments, and simple puns. He loves teaching code, from the fundamentals of algorithmic thinking to the business logic and user flow of application building—he particularly enjoys teaching JavaScript, Python, API design, and front-end frameworks.

Colin has taught code to a diverse group of students since learning to code himself, including young men of color at All-Star Code, elementary school kids at The Coding Space, and marginalized groups at Pursuit. He also works as an instructor for Noble Desktop, where he teaches classes in the Full-Stack Web Development Certificate and the Data Science & AI Certificate.

Colin lives in Brooklyn with his wife, two kids, and many intricate board games.

More articles by Colin Jaffe

How to Learn Machine Learning

Build practical, career-focused machine learning skills through hands-on training designed for beginners and professionals alike. Learn fundamental tools and workflows that prepare you for real-world projects or industry certification.