• 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
Answer from stackoverflowuser2010 on Stack Overflow
🌐
Medium
medium.com › @amit25173 › understanding-percentiles-in-pandas-369166d19e76
Understanding Percentiles in Pandas | by Amit Yadav | Medium
March 6, 2025 - What’s the difference between percentile and quantile in pandas? Answer: quantile() is a pandas method where you provide a value between 0 and 1 (e.g., 0.75 for the 75th percentile).
Discussions

python - Find percentile stats of a given column - Stack Overflow
I am wondering is it possible to find more detailed statistics such as the 90th percentile? ... Save this answer. ... Show activity on this post. You can use the pandas.DataFrame.quantile() function. More on stackoverflow.com
🌐 stackoverflow.com
Numpy percentile and Pandas quantile not identical?
Too early to parse the syntax but off the top of my head both approaches probably use different interpolation methods. I know you can specify the interpolation method in pandas, maybe numpy has a similar argument. Edit: A quick glance at the docs suggest they both use linear interpolation by default, how different are your results? More on reddit.com
🌐 r/learnpython
2
2
January 31, 2019
Inverse function of `quantile()`
Try ecdf(x)(value) More on reddit.com
🌐 r/rstats
5
7
June 5, 2024
How do I get the 90th percentile of a grouped Pandas dataframe?
https://pandas.pydata.org/docs/reference/api/pandas.core.groupby.DataFrameGroupBy.quantile.html More on reddit.com
🌐 r/learnpython
1
1
April 29, 2021
🌐
Medium
medium.com › @amit25173 › understanding-pandas-dataframe-quantile-method-a4949d6807c4
Understanding pandas.DataFrame.quantile() Method | by Amit Yadav | Medium
March 6, 2025 - Both give you the same output. The only difference is that quantile(0.5) is more flexible—you can adjust q to get different percentiles.
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
🌐
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 - Updated in April 2023: I have updated ... the post to reflect changes made in Pandas 2.0. ... A percentile refers to a number where certain percentages fall below that number....
🌐
Enterprise DNA
blog.enterprisedna.co › pandas-percentile-calculate-percentiles-of-a-dataframe
Enterprise DNA: We Help Businesses Put Data and AI to Work
Learn data and AI skills on the platform, bring us in on a project, or run a managed Omni Command Centre. 220K+ professionals trained, 1,500+ companies impacted globally.
Find elsewhere
🌐
Reddit
reddit.com › r/learnpython › numpy percentile and pandas quantile not identical?
r/learnpython on Reddit: Numpy percentile and Pandas quantile not identical?
January 31, 2019 -

Hey, I read that numpy percentile method is faster than pandas quantile while being identical in output, but when I run it on a csv, I don't get an identical output. Are the two statements below not identical for cutting the bottom 10% out of a column?

This:

df = df[df["x"] > numpy.percentile(df["x"], 10)]

Produces a different result to this:

df["x"] = df["x"][df["x"] > df["x"].quantile(.10)]

df = df.dropna()

🌐
Kaggle
kaggle.com › code › aungdev › np-percentile-vs-np-quantile
np.percentile() vs. np.quantile()
June 18, 2023 - np.percentile() vs. np.quantile()Percentiles and QuantilesInterpolation MethodConclusion · This Notebook has been released under the Apache 2.0 open source license. Input1 file · arrow_right_alt · Output0 files · arrow_right_alt · Logs20.1 second run - successful ·
🌐
Naysan
naysan.ca › 2020 › 05 › 24 › quartiles-quantiles-and-percentiles
Quartiles, Quantiles and Percentiles | Naysan Saran
May 24, 2020 - The difference is that the quantile goes from 0 to 1, and the percentile goes from 0% to 100%.
🌐
GeeksforGeeks
geeksforgeeks.org › python › calculate-arbitrary-percentile-on-pandas-groupby
Calculate Arbitrary Percentile on Pandas GroupBy - GeeksforGeeks
July 23, 2025 - The quantile() function takes a value between 0 and 1, where 0.5 represents the median (50th percentile), 0.9 represents the 90th percentile, and so on. ... # import pandas module import pandas as pd # Sample dataset data = { 'Category': ['A', ...
🌐
GeeksforGeeks
geeksforgeeks.org › python › pandas-dataframe-quantile
Pandas DataFrame quantile() Method | Find Quantile Values - GeeksforGeeks
July 11, 2025 - Pandas quantile() function returns values at the given quantile over the requested axis.
🌐
Note.nkmk.me
note.nkmk.me › home › python › pandas
pandas: Find the quantile with quantile() | note.nkmk.me
January 19, 2024 - In statistics and probability, ... have special names, such as quartiles (four groups), deciles (ten groups), and percentiles (100 groups)....
🌐
GeeksforGeeks
geeksforgeeks.org › python › finding-the-quantile-and-decile-ranks-of-a-pandas-dataframe-column
Finding the Quantile and Decile Ranks of a Pandas DataFrame column - GeeksforGeeks
December 20, 2021 - Quartiles are also quantiles; they divide the distribution into four equal parts. Percentiles are quantiles that divide a distribution into 100 equal parts and deciles are quantiles that divide a distribution into 10 equal parts.
🌐
Pythontic
pythontic.com › pandas › series-computations › quantile
Computing quantiles-Percentiles, Quintiles, Deciles, Quarters | Pythontic.com
Percentiles: They divide the distribution into hundredths. Quintiles: They divide the distribution as parts of fifths. Deciles: They divide the distribution into parts of tenths. Quarters: They divide the distribution into quarters. Series.quartile() function returns the specific value of a ...
🌐
RS Blog
reneshbedre.com › blog › quantile-vs-percentile-python.html
Quantile vs Percentile in Python
October 7, 2023 - Quantiles divide the dataset into any number of equal parts. Quartiles and percentiles are parts of quantiles.
🌐
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 - Choose the method that best suits your needs; numpy.percentile for more flexibility or Pandas' quantile for simplicity.
🌐
Pythontic
pythontic.com › pandas › dataframe-computations › quantile
Computing quantile values for a pandas DataFrame | Pythontic.com
The quantile() function of Pandas DataFrame class computes the value below which a given portion of the data lies. The example 2 plots a normal distribution for a value of student scores and marks the deciles in the normal curve as given in the diagram below.