0

I am trying to figure out a way in which I can calculate quantiles in pandas or python based on a column value? Also can I calculate multiple different quantiles in one output?

For example I want to calculate the 0.25, 0.50 and 0.9 quantiles for

Column Minutes in df where it is <= 5 and where it is > 5 and <=10

df[df['Minutes'] <=5]

df[(df['Minutes'] >5) & (df['Minutes']<=10)]

where column Minutes is just a column containing value of numerical minutes

Thanks!

1 Answer 1

3

DataFrame.quantile accepts values in array,

Try

df['minute'].quantile([0.25, 0.50 , 0.9])

Or filter the data first,

df.loc[df['minute'] <= 5, 'minute'].quantile([0.25, 0.50 , 0.9])
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.