如何计算pyspark的中位数?

时间:2018-09-04 20:07:47

标签: python apache-spark pyspark apache-spark-sql

在pyspark中,我们如何计算中位数,因为它们不是pyspark提供的功能。

我想计算某个分区上某个数据框的中位数和某列上的中位数。

For example if there are odd number of rows then (n+1)/2  is the median.
In case of (1,2,3,4,5) then 3 is the median .
But while you take the average of the middle two values like in case of 1,2,3,4 
then (2+3)/2 i.e 2.5 is the median.

有人可以对此进行说明吗?

0 个答案:

没有答案
相关问题