i have some data
a = pd.DataFrame([1,22,34,55,66,75,2,7,8,9,99,70,45,56,22,12,5,9,3,5,89,67,42,21])
when i use the describe function i get these below results:
a.describe()
Out[6]:
0
count 24.000000
mean 34.333333
std 30.786314
min 1.000000
25% 7.750000
50% 22.000000
75% 58.500000
max 99.000000
i get results showing the data in 0 to 25% , 25% to 50% and 50% to 75%. i want to get results such that it shows results in 10%, 20% 30%... so on. Please let me know how to get these results.
You can use Numpy quantile
by giving parameter q
at required percentages like:
np.quantile(a,q=np.linspace(0.1,1,num=10))
array([ 3.6, 6.2, 8.9, 13.8, 22. , 40.4, 55.1, 66.4, 73.5, 99. ])
The quantile range is 10% to 100%:
np.linspace(0.1,1,num=10)
array([0.1, 0.2, 0.3, 0.4, 0.5, 0.6, 0.7, 0.8, 0.9, 1. ])
Or using Numpy percentile
:
np.percentile(a,q=np.linspace(10,100,num=10))
array([ 3.6, 6.2, 8.9, 13.8, 22. , 40.4, 55.1, 66.4, 73.5, 99. ])
The percentile range is 10% to 100%:
np.linspace(10,100,num=10)
array([ 10., 20., 30., 40., 50., 60., 70., 80., 90., 100.])