通过字符串索引选择 Pandas DataFrame 行

use*_*903 5 python dataframe pandas

我有一个以下形式的 pandas 数据框:

在此输入图像描述

其中“it”、“their”和“charact”是索引。如何根据索引选择一个值?当我尝试以下操作时:

corpus_df.iloc['it',1]
Run Code Online (Sandbox Code Playgroud)

我收到错误:

ValueError: Location based indexing can only have [integer, integer slice (START point is INCLUDED, END point is EXCLUDED), listlike of integers, boolean array] types
Run Code Online (Sandbox Code Playgroud)

Ahm*_*med 10

你可以corpus_df.loc['it'][1]使用