获取满足条件的Pandas DataFrame行的整数索引? [英] Getting the integer index of a Pandas DataFrame row fulfilling a condition?

查看:194
本文介绍了获取满足条件的Pandas DataFrame行的整数索引?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有以下DataFrame:

I have the following DataFrame:

   a  b  c
b
2  1  2  3
5  4  5  6

如您所见,列b用作索引.我想获取满足('b' == 5)的行的序号,在这种情况下为1.

As you can see, column b is used as an index. I want to get the ordinal number of the row fulfilling ('b' == 5), which in this case would be 1.

要测试的列可以是索引列(在这种情况下,如b)或常规列,例如我可能想找到满足('c' == 6)的行的索引.

The column being tested can be either an index column (as with b in this case) or a regular column, e.g. I may want to find the index of the row fulfilling ('c' == 6).

推荐答案

您可以使用返回的值是一个数组,因为一列中可能有多个具有特定索引或值的行.

The value returned is an array since there could be more than one row with a particular index or value in a column.

这篇关于获取满足条件的Pandas DataFrame行的整数索引?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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