![](/img/trans.png)
[英]Why is the first row of my pandas dataframe index the name of the index column?
[英]Pandas dataframe select row by index and column by name
使用 Index 的get_loc
方法获取列名的整数位置。
假设这个数据框:
>>> df
A B C
10 1 2 3
11 4 5 6
12 7 8 9
您可以像这样使用.iloc
:
>>> df.iloc[1, df.columns.get_loc('B')]
5
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.