First of all, according to the docs, the default method used for interpolation is linear:

linear: i + (j - i) * fraction, where fraction is the fractional part of the index surrounded by i and j.

We first need to find out how index is calculated (and then get its fractional part):

index = distance_between_first_and_last_element * q

So, in your example, we'd have a distance of 7 (because 2 and 19 are 7 positions apart). This leads to:

 index = 7 * 0.3 = 2.1

Of course, we need to keep only the fractional part of it, which is simply 0.1, so fraction is equal to 0.1.

Moreover, the 0.3 quantile that you've asked for is between 5 and 8 (which are numbers in your list), so these will stand for i and j respectively.

Why? Because your index is 2.1, which is between 2 and 3, so:

i = s[2] # which is equal to 5 in your Series
j = s[3] # which is equal to 8 in your Series

All these lead to:

5 + (8-5) * 0.1

which equals to:

5.3

According to the same logic, we can calculate the 0.25 percentile:

index = 7 * 0.25 # 1.75
fraction = 0.75 # the fractional part of index
i = s[1] # 4
j = s[2] # 5
answer = 4 + (5-4) * 0.75 -> 4.75
Answer from theodosis on Stack Overflow
🌐
Pandas
pandas.pydata.org › docs › reference › api › pandas.Series.quantile.html
pandas.Series.quantile — pandas 3.0.2 documentation
Calculate the rolling quantile. ... Returns the q-th percentile(s) of the array elements. ... >>> s = pd.Series([1, 2, 3, 4]) >>> s.quantile(0.5) 2.5 >>> s.quantile([0.25, 0.5, 0.75]) 0.25 1.75 0.50 2.50 0.75 3.25 dtype: float64
🌐
GeeksforGeeks
geeksforgeeks.org › pandas › python-pandas-series-quantile
Python | Pandas Series.quantile() - GeeksforGeeks
November 25, 2022 - Output : Now we will use Series.quantile() function to find the 40% quantile of the underlying data in the given series object.
🌐
Medium
medium.com › @amit25173 › understanding-pandas-dataframe-quantile-method-a4949d6807c4
Understanding pandas.DataFrame.quantile() Method | by Amit Yadav | Medium
March 6, 2025 - Let’s keep this simple: The quantile() method in pandas helps you figure out the value below which a certain percentage of your data falls.
🌐
Apache
spark.apache.org › docs › latest › api › python › reference › pyspark.pandas › api › pyspark.pandas.Series.quantile.html
pyspark.pandas.Series.quantile — PySpark 4.1.1 documentation
Unlike pandas’, the quantile in pandas-on-Spark is an approximated quantile based upon approximate percentile computation because computing quantile across a large dataset is extremely expensive. ... Default accuracy of approximation. Larger value means better accuracy.
🌐
Snowflake Documentation
docs.snowflake.com › en › developer-guide › snowpark › reference › python › 1.39.0 › modin › pandas_api › modin.pandas.Series.quantile
modin.pandas.Series.quantile | Snowflake Documentation
>>> s = pd.Series([None, 0, 25, 50, 75, 100, np.nan]) >>> s.quantile([0, 0.25, 0.5, 0.75, 1]) 0.00 0.0 0.25 25.0 0.50 50.0 0.75 75.0 1.00 100.0 dtype: float64
🌐
Vultr Docs
docs.vultr.com › python › third-party › pandas › DataFrame › quantile
Python Pandas DataFrame quantile() - Compute Quantiles
December 24, 2024 - Quantiles are vital statistics in data analysis, commonly used to understand the distribution and spread of data points. The quantile() method in the Python Pandas library is a powerful tool for computing quantiles from data series or DataFrames, ...
Find elsewhere
🌐
Pandas
pandas.pydata.org › pandas-docs › version › 0.14 › generated › pandas.Series.quantile.html
pandas.Series.quantile — pandas 0.14.1 documentation
Contributing to pandas · Release Notes · Enter search terms or a module, class or function name. Series.quantile(q=0.5)¶ · Return value at the given quantile, a la numpy.percentile. Examples · >>> s = Series([1, 2, 3, 4]) >>> s.quantile(.5) 2.5 >>> s.quantile([.25, .5, .75]) 0.25 1.75 0.50 2.50 0.75 3.25 dtype: float64 ·
🌐
W3Schools
w3schools.com › Python › pandas › ref_df_quantile.asp
Pandas DataFrame quantile() Method
dataframe.quantile(q, axis, numeric_only, unterpolation) The q, axis, numeric_only parameters are keyword arguments. A Series or a DataFrame object with the quantiles.
🌐
GeeksforGeeks
geeksforgeeks.org › pandas-dataframe-quantile
Pandas DataFrame quantile() Method | Find Quantile Values - GeeksforGeeks
February 1, 2024 - -> If q is a float, a Series will be returned where the index is the columns of self and the values are the quantiles. Let's see some examples of how to find values of a given quantile using the quantile() function of the Pandas library.
🌐
Finxter
blog.finxter.com › exploring-quantiles-in-python-pandas-series
Exploring Quantiles in Python Pandas Series – Be on the Right Side of Change
February 19, 2024 - For example, given a Series of ... approach offered by Pandas. The Series.quantile(q) function returns the value at the given quantile q, where q is a float representing the quantile to compute, ranging from 0 to 1....
🌐
Readthedocs
eland.readthedocs.io › en › v8.13.0 › reference › api › eland.DataFrame.quantile.html
eland.DataFrame.quantile - eland 8.13.0 documentation
>>> ed_df = ed.DataFrame('http://localhost:9200', 'flights') >>> ed_flights = ed_df.filter(["AvgTicketPrice", "FlightDelayMin", "dayOfWeek", "timestamp"]) >>> ed_flights.quantile() AvgTicketPrice 640.387285 FlightDelayMin 0.000000 dayOfWeek 3.000000 Name: 0.5, dtype: float64
🌐
Readthedocs
eland.readthedocs.io › en › v7.14.0b1 › reference › api › eland.Series.quantile.html
eland.Series.quantile — eland 7.14.0b1 documentation
Series.quantile(q: Union[int, float, List[int], List[float]] = 0.5) → Union[pandas.core.series.Series, Any]¶ · Used to calculate quantile for a given Series. Parameters · q: float or array like, default 0.5 Value between 0 <= q <= 1, the quantile(s) to compute.
🌐
Databricks
api-docs.databricks.com › python › pyspark › latest › pyspark.pandas › api › pyspark.pandas.DataFrame.quantile.html
pyspark.pandas.DataFrame.quantile — PySpark master documentation
If q is a float, a Series will be returned where the index is the columns of self and the values are the quantiles. Examples · >>> psdf = ps.DataFrame({'a': [1, 2, 3, 4, 5], 'b': [6, 7, 8, 9, 0]}) >>> psdf a b 0 1 6 1 2 7 2 3 8 3 4 9 4 5 0 · >>> psdf.quantile(.5) a 3.0 b 7.0 Name: 0.5, dtype: ...