Python Pandas:按中位数获取行 [英] Python Pandas: Get row by median value

查看:1119
本文介绍了Python Pandas:按中位数获取行的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试获取一列中值的行.

I'm trying to get the row of the median value for a column.

我正在使用data.median()来获取列"的中值.

I'm using data.median() to get the median value for 'column'.

id                 30444.5
someProperty           3.0
numberOfItems          0.0
column                70.0

然后是data.median()['column']:

And data.median()['column'] is subsequently:

data.median()['performance']
>>> 70.0

如何获取中间值的行或索引? 有什么类似于idxmax/idxmin吗?

How can get the row or index of the median value? Is there anything similar to idxmax / idxmin?

我尝试过滤,但是在多行具有相同值的情况下不可靠.

I tried filtering but it's not reliable in cases multiple rows have the same value.

谢谢!

推荐答案

可能只是:data[data.performance==data.median()['performance']].

这篇关于Python Pandas:按中位数获取行的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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