Skip to content
masterclassBuddyTech Buzz5 fresh blogs · 5:00 AM IST

Pandas · Module

df.at

DataFrame.at reads or writes one cell using a row-label and column-label pair. It is the label-based scalar counterpart to positional iat.

How it works

DataFrame.at provides scalar access using a row label and a column label. It supports both retrieval and assignment, making it suitable when exactly one cell is involved rather than a multi-cell selection.

Syntax

DataFrame.at[row_label, column_label]

Returns

The value at the specified row/column label pair when reading; assignment updates that cell.

Key points

  • Use DataFrame.at to address one cell through its row and column labels.
  • Its lookup semantics are label-based, like loc.
  • Choose it for scalar reads or writes rather than multi-cell selection.
  • A bracketed row/column pair returns the selected cell's value.
  • Assigning to the same indexer changes the selected cell.

Common mistakes

  • Reading a missing row or column label raises KeyError.
  • For a DataFrame, the indexer must represent a row/column pair, and each label must be scalar.

Example: Read and update one labeled cell

import pandas as pd

df = pd.DataFrame(
    [[0, 2, 3], [0, 4, 1], [10, 20, 30]],
    columns=["A", "B", "C"],
)

value = df.at[1, "B"]
df.at[1, "B"] = 10

assert value == 4
assert df.at[1, "B"] == 10

Use the label pair inside brackets to read one cell, or assign through the same expression to update it.

When to use it

Scalar lookup

Read one known cell from a labeled table without selecting a larger slice.

Scalar update

Change one field identified by its row and column labels.

Series scalar access

Work with a Series obtained from a DataFrame row.

Interview questions

QWhat is DataFrame.at used for?

at performs label-based scalar access on a DataFrame. It can retrieve or assign one value identified by a row label and a column label.

Follow-up: How would you access one cell by position instead of labels? Use iat, which provides integer-position-based scalar access.

QHow does at differ from loc?

Both at and loc use labels, but at is intended for a single value. Use loc when selecting groups of rows or columns.

Follow-up: What is the positional counterpart of loc? iloc selects by integer positions, while iat is the scalar positional counterpart.

QHow do you update a single DataFrame cell with at?

Read with df.at[row_label, column_label] and assign with df.at[row_label, column_label] = value. The same labeled expression identifies the target cell in both cases.

Follow-up: What happens if the requested label is absent during a read? A missing label causes KeyError.

  • DataFrame.iat
  • DataFrame.loc
  • DataFrame.iloc

Source: pandas.DataFrame.at. Checked 2026-10-15.