在Pandas中查找行索引和列索引值

时间:2020-05-21 08:56:15

标签: python pandas

我想通过给出确定的列号来找到行的索引。

Dataset.zip

enter image description here

如何找到它?

2 个答案:

答案 0 :(得分:0)

要获取它,您必须通过以下方式使用iloc:

print(df.iloc[1][1])

答案 1 :(得分:0)

您可以使用.iloc属性。下面是一个示例:

  df.iloc[1,2]

这将在第1行和第2列获取对象。

您甚至可以使用冒号进行拼接。示例:

  df.iloc[2:5 , 3:8]

这将从第2到5行以及第3到8行获取所有元素。

有关iloc的更多信息,请参见:

https://thispointer.com/select-rows-columns-by-name-or-index-in-dataframe-using-loc-iloc-python-pandas/

希望这会有所帮助

相关问题