python pandas 3最小& 3个最大值 [英] python pandas 3 smallest & 3 largest values

查看:65
本文介绍了python pandas 3最小& 3个最大值的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何在熊猫数据框中的一列中找到3个最小和3个最大值的索引?我看到了找到最大值和最小值的方法,但是没有找到最大值和最小值的方法.

How can I find the index of the 3 smallest and 3 largest values in a column in my pandas dataframe? I saw ways to find max and min, but none to get the 3.

推荐答案

您尝试了什么?您可以使用s.sort()进行排序,然后调用s.head(3).indexs.tail(3).index.

What have you tried? You could sort with s.sort() and then call s.head(3).index and s.tail(3).index.

这篇关于python pandas 3最小& 3个最大值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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