2

I have a dataframe called df

df['value'] has values like (10,9,6,1,6,6,5,12,8,17,10,6,......,10,19,6,18,11) 

I want to find the number that mark the 69.1% of the data

I managed to find this

df['value'].describe(percentiles=np.linspace(0, 1, 101)) 

which gives me each percent value, except i want it for 0.1 percent and I dont think I want to find that

df['value'].describe(percentiles=np.linspace(0, 1, 1001)) 

is practical, I wonder if there is another direct way to get the number that marks a certain percentage

2 Answers 2

2

Use pd.Series.quantile:

import pandas as pd s = pd.Series([10,9,6,1,6,6,5,12,8,17,10,6,10,19,6,18,11]) # sample series s.quantile(0.691, 'nearest') 

Output:

10 
Sign up to request clarification or add additional context in comments.

Comments

1

pandas has a built-in function for this, so you can just do df['value'].quantile(0.691).

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.