You can do this using rank, where pct=True option displays ranks in percentile form.

In [1551]: v = pd.Series([0,2,4,2,10,8,6,1])
In [1556]: v.rank(pct=True)                 
Out[1556]: 
0    0.1250
1    0.4375
2    0.6250
3    0.4375
4    1.0000
5    0.8750
6    0.7500
7    0.2500
dtype: float64
Answer from Mayank Porwal on Stack Overflow
🌐
Pandas
pandas.pydata.org › docs › reference › api › pandas.Series.quantile.html
pandas.Series.quantile — pandas 3.0.6 documentation
If q is an array, a Series will be returned where the index is q and the values are the quantiles, otherwise a float will be returned. ... Calculate the rolling quantile. ... Returns the q-th percentile(s) of the array elements.
🌐
Pandas
pandas.pydata.org › pandas-docs › stable › reference › api › pandas.Series.quantile.html
pandas.Series.quantile — pandas 3.0.5 documentation
If q is an array, a Series will be returned where the index is q and the values are the quantiles, otherwise a float will be returned. ... Calculate the rolling quantile. ... Returns the q-th percentile(s) of the array elements.
🌐
Medium
medium.com › @amit25173 › understanding-percentiles-in-pandas-369166d19e76
Understanding Percentiles in Pandas | by Amit Yadav | Medium
March 6, 2025 - If you’re dealing with percentiles in Python, NumPy’s percentile() is your go-to tool. It’s fast, simple, and perfect for quick calculations. ... import numpy as np import pandas as pd # Sample data data = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100] # Finding the 90th percentile percentile_90 = np.percentile(data, 90) print("90th Percentile:", percentile_90)
🌐
datagy
datagy.io › home › pandas tutorials › data analysis in pandas › pandas quantile: calculate percentiles of a dataframe
Pandas Quantile: Calculate Percentiles of a Dataframe • datagy
April 16, 2023 - The Pandas quantile method works on either a Pandas series or an entire Pandas Dataframe. By default, it returns the 50th percentile and interpolates the data using linear interpolation.
🌐
Spark By {Examples}
sparkbyexamples.com › home › pandas › pandas series.quantile() function
Pandas Series.quantile() Function - Spark By {Examples}
March 27, 2024 - In Pandas, the Series.quantile() function is used to compute the quantiles of a Series. Quantiles are statistical values that divide the data into four
Find elsewhere
🌐
Data Science Dojo
discuss.datasciencedojo.com › python
How to calculate median, 25th, and 75th percentile values in a Pandas Series? - Python - Data Science Dojo Discussions
February 27, 2023 - I was learning and exploring some series statistics that are normally used in the analysis of the data and found out about the median value, the 25th percentile value, and the 75th percentile value. Can someone provide m…
🌐
w3resource
w3resource.com › python-exercises › pandas › python-pandas-data-series-exercise-18.php
Pandas Data Series: Compute the minimum, 25th percentile, median, 75th, and maximum of a given series - w3resource
The 'q' parameter specifies the percentiles to calculate, with the values [0, 25, 50, 75, 100] indicating the minimum value, the lower quartile (25th percentile), the median (50th percentile), the upper quartile (75th percentile), and the maximum ...
🌐
Note.nkmk.me
note.nkmk.me › home › python › pandas
pandas: Find the quantile with quantile() | note.nkmk.me
January 19, 2024 - import pandas as pd print(pd._... # 9 9 81 # 10 10 100 ... By default, the quantile() method on a DataFrame returns the median (the second quartile or 50th percentile) for each column. This result is presented as a ...
🌐
Pandas
pandas.pydata.org › pandas-docs › version › 0.23 › generated › pandas.Series.quantile.html
pandas.Series.quantile — pandas 0.23.1 documentation
Extending Pandas · Release Notes · Enter search terms or a module, class or function name. Series.quantile(q=0.5, interpolation='linear')[source]¶ · Return value at the given quantile, a la numpy.percentile. See also · pandas.core.window.Rolling.quantile ·
🌐
GeeksforGeeks
geeksforgeeks.org › pandas › python-pandas-series-quantile
Python | Pandas Series.quantile() - GeeksforGeeks
November 25, 2022 - Pandas Series.quantile() function return value at the given quantile for the underlying data in the given Series object.
🌐
Saturn Cloud
saturncloud.io › blog › how-to-find-percentile-stats-of-a-given-column-using-pandas
How to Find Percentile Stats of a Given Column Using Pandas | Saturn Cloud Blog
May 1, 2026 - Use the quantile() function to find the percentile statistics. Let’s dive into each step in detail. To use Pandas, we first need to import the library.
🌐
GeeksforGeeks
geeksforgeeks.org › percentile-rank-of-a-column-in-a-pandas-dataframe
Percentile rank of a column in a Pandas DataFrame - GeeksforGeeks
August 17, 2020 - Let us see how to find the percentile rank of a column in a Pandas DataFrame. We will use the rank() function with the argument pct = True to find the percentile rank.
🌐
GeeksforGeeks
geeksforgeeks.org › how-to-print-values-above-75th-percentile-from-series-using-quantile-using-pandas
Print values above 75th percentile from series Using Quantile using Pandas | GeeksforGeeks
July 31, 2023 - There is a series of data, we have to find all the values of the series object whose value is greater than the 75th Percentile. ... Inside for loop, we'll check whether the value is greater than the 75th quantile value that is calculated in ...
🌐
Data Science Parichay
datascienceparichay.com › home › blog › calculate percentile in python
Calculate Percentile in Python - Data Science Parichay
October 9, 2021 - You can also use the pandas quantile() function to get the nth percentile of a pandas series or a dataframe in python.
Top answer
1 of 6
183
  • You can use the pandas.DataFrame.quantile() function.
    • If you look at the API for quantile(), you will see it takes an argument for how to do interpolation. If you want a quantile that falls between two positions in your data:
      • 'linear', 'lower', 'higher', 'midpoint', or 'nearest'.
      • By default, it performs linear interpolation.
      • These interpolation methods are discussed in the Wikipedia article for percentile
import pandas as pd
import numpy as np

# sample data 
np.random.seed(2023)  # for reproducibility
data = {'Category': np.random.choice(['hot', 'cold'], size=(10,)),
        'field_A': np.random.randint(0, 100, size=(10,)),
        'field_B': np.random.randint(0, 100, size=(10,))}
df = pd.DataFrame(data)

df.field_A.mean()  # Same as df['field_A'].mean()
# 51.1

df.field_A.median() 
# 50.0

# You can call `quantile(i)` to get the i'th quantile,
# where `i` should be a fractional number.

df.field_A.quantile(0.1)  # 10th percentile
# 15.6

df.field_A.quantile(0.5)  # same as median
# 50.0

df.field_A.quantile(0.9)  # 90th percentile
# 88.8

df.groupby('Category').field_A.quantile(0.1)
#Category
#cold    28.8
#hot      8.6
#Name: field_A, dtype: float64

df

  Category  field_A  field_B
0     cold       96       58
1     cold       22       28
2      hot       17       81
3     cold       53       71
4     cold       47       63
5      hot       77       48
6     cold       39       32
7      hot       69       29
8      hot       88       49
9      hot        3       49
2 of 6
39

assume series s

s = pd.Series(np.arange(100))

Get quantiles for [.1, .2, .3, .4, .5, .6, .7, .8, .9]

s.quantile(np.linspace(.1, 1, 9, 0))

0.1     9.9
0.2    19.8
0.3    29.7
0.4    39.6
0.5    49.5
0.6    59.4
0.7    69.3
0.8    79.2
0.9    89.1
dtype: float64

OR

s.quantile(np.linspace(.1, 1, 9, 0), 'lower')

0.1     9
0.2    19
0.3    29
0.4    39
0.5    49
0.6    59
0.7    69
0.8    79
0.9    89
dtype: int32