从pandas数据框中获取索引值

bes*_*shr 6 python indexing series pandas

我有一个 Pandas 数据框(国家),需要获取特定的索引值。(说索引 2 => 我需要日本)

系列

我使用了 il​​oc,但我得到了数据(7.542)

return countries.iloc[2]
7.542
Run Code Online (Sandbox Code Playgroud)

sud*_*nym 11

直接调用索引

return countries.index[2]
Run Code Online (Sandbox Code Playgroud)

但你在这里发布的内容看起来像一个 pandas 数据框而不是一个系列 - 如果是这样的话

countries['Country_Name'].iloc[2]
Run Code Online (Sandbox Code Playgroud)