Pandas .. 分位数函数需要排序数据来计算百分位数吗? [英] Pandas.. does quantile function need sorted data to calculate percentiles?

查看:382
本文介绍了Pandas .. 分位数函数需要排序数据来计算百分位数吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用 Pandas 清理一些数据并进行基本统计.我想知道 quantile() 是否在计算之前对值进行排序,还是我必须事先进行排序?

I'm using Pandas to clean up some data and do basic statistics. I am wondering if quantile() does sort the values before the calculation or i must do the sorting beforehand?

例如,这里我试图获取每家公司员工人数的第 50 个百分位

For example, here I'm trying to get the 50th percentile of the number of workers in each company

Percentile50th = Y2015_df.groupby (["company"])["worker"].quantile(0.50)

我之所以这么问是因为当我在 MS Excel 中验证得到的值时,我发现 Median 函数需要对数据进行排序才能获得正确的中值.但我不确定 Pandas 是否是这种情况.

I'm asking because when I was verifying the values I got with the results in MS Excel, I discovered that Median function requires the data to be sorted in order to get the right median. But I'm not sure if its the case in Pandas.

推荐答案

您不需要排序.请参阅我之前评论中的链接.示例

You do not need to sort. See the link in my previous comment. Example

这篇关于Pandas .. 分位数函数需要排序数据来计算百分位数吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆