Scalar lookup
Read one known cell from a labeled table without selecting a larger slice.
Pandas · Module
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.
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.
DataFrame.at[row_label, column_label]The value at the specified row/column label pair when reading; assignment updates that cell.
DataFrame.at to address one cell through its row and column labels.loc.KeyError.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"] == 10Use the label pair inside brackets to read one cell, or assign through the same expression to update it.
Read one known cell from a labeled table without selecting a larger slice.
Change one field identified by its row and column labels.
Work with a Series obtained from a DataFrame row.
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.
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.
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.iatDataFrame.locDataFrame.iloc