pandas - 如何访问pandas中的单元格,相当于R中的df [3,4] [英] pandas - how to access cell in pandas, equivalent of df[3,4] in R
本文介绍了pandas - 如何访问pandas中的单元格,相当于R中的df [3,4]的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
如果我有一个pandas DataFrame对象,我该如何简单地访问一个单元?在R中,假设我的data.frame被称为df,我可以访问第3行和第4列
If I have a pandas DataFrame object, how do I simply access a cell? In R, assuming my data.frame is called df, I can access the 3rd row and 4th column by
df[3,4]
python中的等价物是什么?
What is the equivalent in python?
推荐答案
您可以使用iloc(通过位置获取):
You can use iloc (to get by position):
df.iloc[3,4]
我建议阅读< a href =http://pandas.pydata.org/pandas-docs/stable/indexing.html>文档的索引部分。
这篇关于pandas - 如何访问pandas中的单元格,相当于R中的df [3,4]的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文