pandas - how to access cell in pandas, equivalent of df[3,4] in R

后端 未结 2 1025
野的像风
野的像风 2020-12-29 21:20

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         


        
相关标签:
2条回答
  • 2020-12-29 21:50

    You can use iloc (to get by position):

    df.iloc[3,4]
    

    I recommend reading the indexing section of the docs.

    0 讨论(0)
  • 2020-12-29 21:59

    If you want to access the cell based on the column and row labels, use at:

    df.at["Year","Temperature"]
    

    This will return the cell intersected by the row "Year" and the column "Temperature".

    0 讨论(0)
提交回复
热议问题