How to get a value from a cell of a dataframe?

If you have a DataFrame with only one row, then access the first (only) row as a Series using iloc, and then the value using the column name:

In [3]: sub_df
          A         B
2 -0.133653 -0.030854

In [4]: sub_df.iloc[0]
A   -0.133653
B   -0.030854
Name: 2, dtype: float64

In [5]: sub_df.iloc[0]['A']
Out[5]: -0.13365288513107493

Leave a Comment