Access Value at specific Row/Column of DataFrame

To access item/value at specific Row/Column of DataFrame in Pandas, use pandas.DataFrame.at attribute. Specify the row and column in square brackets.

In this tutorial, we will learn how to access value at specific Row/Column of DataFrame in Pandas using DataFrame.at attribute.

Syntax

The syntax to access value/item at given row and column in DataFrame is

DataFrame.at[row, column]

where

  • row is the index of the item’s row.
  • column is the column label for the item.

We may read the value at specified row and column, or may set the value at specified row and column.

Example

Read Value at [Row, Column] in DataFrame

In the following program, we take a DataFrame and read the value at second row and 'name' column.

Example.py

import pandas as pd

df = pd.DataFrame(
    {'name': ["apple", "banana", "cherry"], 'quant': [40, 50, 60]})
item = df.at[1, 'name']
print(item)
Try Online

Output

banana

Update Value at [Row, Column] in DataFrame

In the following program, we take a DataFrame and update the value at second row and 'name' column to 'mango'.

Example.py

import pandas as pd

df = pd.DataFrame(
    {'name': ["apple", "banana", "cherry"], 'quant': [40, 50, 60]})
df.at[1, 'name'] = "mango"
print(df)
Try Online

Output

name  quant
0   apple     40
1   mango     50
2  cherry     60

Conclusion

In this Pandas Tutorial, we learned how to access item/value at specific Row/Column of DataFrame using DataFrame().at attribute.