【问题标题】:Pandas.. does quantile function need sorted data to calculate percentiles?Pandas .. 分位数函数是否需要排序数据来计算百分位数?
【发布时间】:2020-01-27 23:39:16
【问题描述】:

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

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

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

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

【问题讨论】:

  • 没有。看看这个。enter link description here
  • @Parth 不,你的意思是它不需要我这边的任何排序,对吧?该功能完成所有工作..只是想仔细检查

标签: python excel pandas


【解决方案1】:

您不需要排序。请参阅我之前评论中的链接。 Example

【讨论】:

  • 非常感谢@Parth
猜你喜欢
  • 2020-10-07
  • 1970-01-01
  • 2021-03-21
  • 1970-01-01
  • 1970-01-01
  • 2011-12-29
  • 2013-06-20
  • 2021-02-26
  • 1970-01-01
相关资源
最近更新 更多