Scalar lookup
Read one known cell efficiently during validation or transformation.
Pandas · Module
DataFrame.iat reads or writes one cell using integer row and column positions. It is the scalar counterpart to broader positional selection with iloc.
DataFrame.iat is a scalar indexer for accessing or changing one cell by its zero-based row and column positions. Unlike label-based at, it selects by integer position and is intended for single-value operations rather than slices or groups.
DataFrame.iat[row, column]| Name | Type | Description |
|---|---|---|
row position | integer | Integer position of the row in the DataFrame. |
column position | integer | Integer position of the column in the DataFrame. |
The scalar value at the requested row and column position when reading; assignment updates the selected cell and does not produce a separate tabular result.
iloc, but its purpose is scalar access rather than selecting groups.iat accessor can retrieve one element by that Series' integer position.import pandas as pd
frame = pd.DataFrame([[10, 20], [30, 40]], columns=["x", "y"])
value = frame.iat[1, 0]
frame.iat[1, 0] = 99
print(value) # 30
print(frame.iat[1, 0]) # 99Use integer row and column positions to read one cell, or assign a new value to that cell.
Read one known cell efficiently during validation or transformation.
Replace one cell without selecting a larger slice.
Retrieve one element after selecting a row as a Series.
DataFrame.iat used for?iat accesses one DataFrame value using integer row and column positions. It can both retrieve a scalar and assign a replacement value.
Follow-up: How would you access a cell by labels instead? Use DataFrame.at, which performs scalar label-based access.
iat differ from iloc?Both iat and iloc use integer-based indexing, but iat is intended for a single value. iloc is the broader positional indexer for groups of rows and columns.
Follow-up: Which accessor is suitable for one value identified by row and column labels? Use at.
iat?For a two-dimensional DataFrame, supply the row position first and the column position second, such as df.iat[1, 2]. The positions are integer coordinates, independent of the displayed index and column labels.
Follow-up: What happens when either coordinate exceeds the DataFrame bounds? Pandas raises IndexError.
DataFrame.atDataFrame.locDataFrame.ilocSeries.iat