- 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

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.

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

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))

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

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 nth value of a Fibonacci series using recursion in C#?
- Print the mean of a Pandas series
- How to sort a Pandas Series?
- Nth element of the Fibonacci series JavaScript
- Accessing elements of a Pandas Series
- How to calculate the frequency of each item in a Pandas series?
- How to append elements to a Pandas series?
- Print the standard deviation of Pandas series
- How to get the row count of a Pandas DataFrame?
- Finding the length of words in a given Pandas series
- Python - How to access the last element in a Pandas series?
- How to get a value from the cell of a Pandas DataFrame?
- JavaScript code to find nth term of a series - Arithmetic Progression (AP)
- Python Program for nth multiple of a number in Fibonacci Series

Advertisements