Use app×
QUIZARD
QUIZARD
JEE MAIN 2026 Crash Course
NEET 2026 Crash Course
CLASS 12 FOUNDATION COURSE
CLASS 10 FOUNDATION COURSE
CLASS 9 FOUNDATION COURSE
CLASS 8 FOUNDATION COURSE
0 votes
95 views
in Artificial Intelligence (AI) by (178k points)
Are there any alternative methods to calculate percentiles in Python?

Please log in or register to answer this question.

1 Answer

0 votes
by (178k points)

Yes, besides NumPy, you can also use the pandas library to calculate percentiles. Here's an example:

import pandas as pd

data = pd.Series([10, 15, 20, 25, 30, 35, 40, 45, 50])

# Calculate the 25th percentile
percentile_25 = data.quantile(0.25)
print("25th percentile:", percentile_25)

# Calculate the 50th percentile (median)
median = data.median()
print("Median:", median)

# Calculate the 75th percentile
percentile_75 = data.quantile(0.75)
print("75th percentile:", percentile_75)
 

The output will be the same as the previous example.

In this case, we create a pandas Series called data and use the quantile() method to calculate the desired percentiles.

Related questions

Welcome to Sarthaks eConnect: A unique platform where students can interact with teachers/experts/students to get solutions to their queries. Students (upto class 10+2) preparing for All Government Exams, CBSE Board Exam, ICSE Board Exam, State Board Exam, JEE (Mains+Advance) and NEET can ask questions from any subject and get quick answers by subject teachers/ experts/mentors/students.

Categories

...