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

If I have a pandas DataFrame object, how can I just access the cell? In R, assuming my data.frame is called df, I can access the third and fourth column with

df[3,4] 

What is the equivalent in python?

+19
pandas indexing dataframe
source share
2 answers

You can use iloc (to get by position):

 df.iloc[3,4] 

I recommend reading the document indexing section.

+26
source share

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

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

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

+15
source share

All Articles