- Trending Categories
- Data Structure
- Networking
- RDBMS
- Operating System
- Java
- iOS
- HTML
- CSS
- Android
- Python
- C Programming
- C++
- C#
- MongoDB
- MySQL
- Javascript
- PHP

- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who

# How to get the nth percentile of a Pandas series?

A percentile is a term used in statistics to express how a score compares to other scores in the same set. In this program, we have to find nth percentile of a Pandas series.

## Algorithm

Step 1: Define a Pandas series. Step 2: Input percentile value. Step 3: Calculate the percentile. Step 4: Print the percentile.

## Example Code

import pandas as pd series = pd.Series([10,20,30,40,50]) print("Series:\n", series) n = int(input("Enter the percentile you want to calculate: ")) n = n/100 percentile = series.quantile(n) print("The {} percentile of the given series is: {}".format(n*100, percentile))

## Output

Series: 0 10 1 20 2 30 3 40 4 50 dtype: int64 Enter the percentile you want to calculate: 50 The 50.0 percentile of the given series is: 30.0

## Explanation

The quantile function in the Pandas library takes values only between 0 and 1 as parameters. Therefore, we have to divide the percentile value by 100 before passing it to the quantile function.

- Related Questions & Answers
- How to get nth row in a Pandas DataFrame?
- How to Get the Position of Max Value of a pandas Series?
- How to Get the Position of Minimum Value of a pandas Series?
- How to get the nth value of a Fibonacci series using recursion in C#?
- How to get the index and values of series in Pandas?
- How to get the length, size, and shape of a series in Pandas?
- How to get few rows from a Series in Pandas?
- How to Get the values from the pandas series between a specific time?
- Nth element of the Fibonacci series JavaScript
- How to get the final rows of a time series data using pandas series.last() method?
- How to check the data type of a pandas series?
- Print the mean of a Pandas series
- How to sort a Pandas Series?
- How to calculate the frequency of each item in a Pandas series?
- How to get the row count of a Pandas DataFrame?

Advertisements