Skip to content
Advertisement

Tag: percentile

Optimal way to acquire percentiles of DataFrame rows

Problem I have a pandas DataFrame df: My desired output, i.e. new_df, contains the 9 different percentiles including the median, and should have the following format: Attempt The following was my initial attempt: However, instead of returning the percentiles of all columns, it calculated these percentiles for each val column and therefore returned 1000 columns. As it calculated the percentiles

How do I calculate percentiles with python/numpy?

Is there a convenient way to calculate percentiles for a sequence or single-dimensional numpy array? I am looking for something similar to Excel’s percentile function. I looked in NumPy’s statistics reference, and couldn’t find this. All I could find is the median (50th percentile), but not something more specific. Answer You might be interested in the SciPy Stats package. It

Advertisement