Вы ищете df.quantile и некоторые основы c математика.
Представление этих значений в таблице не имеет большого значения - это еще три столбца, умноженные на len(df)
все данные одинаковы - поэтому я даю им простые выражения:
import pandas as pd
import random
# some data shuffling to see it works on unsorted data
random.seed(42)
data = [[f"product {i+1:3d}",i*10] for i in range(100)]
random.shuffle(data)
df = pd.DataFrame(data, columns=['name', 'price'])
# calculate the quantile series
q25 = df.quantile(.25, numeric_only=True)
q50 = df.quantile(.5, numeric_only=True)
q75 = df.quantile(.75, numeric_only=True)
print (q25, q50, q75, sep="\n\n")
print( f"Bottom 25% of prices are below/equal to {q25.price} thats", end=" ")
print( f"{len(df[df.price <= q25.price]) / (len(df) / 100)}% of all items")
print( f"Bottom 50% of prices are below/equal to {q50.price} thats", end=" ")
print( f"{len(df[df.price <= q50.price]) / (len(df) / 100)}% of all items")
print( f"Bottom 75% of prices are below/equal to {q75.price} thats", end= " ")
print( f"{len(df[df.price <= q75.price]) / (len(df)/ 100)}% of all items")
(Unshuffled) Dataframe выглядит как
name price
0 product 1 0
1 product 2 10
2 product 3 20
.. ... ...
97 product 98 970
98 product 99 980
99 product 100 990
[100 rows x 2 columns]
Вывод:
price 247.5
Name: 0.25, dtype: float64
price 495.0
Name: 0.5, dtype: float64
price 742.5
Name: 0.75, dtype: float64
Bottom 25% of prices are below/equal to 247.5 thats 25.0% of all items
Bottom 50% of prices are below/equal to 495.0 thats 50.0% of all items
Bottom 75% of prices are below/equal to 742.5 thats 75.0% of all items