iat[] is to iloc[] exactly what at[] is to loc[]: a scalar-only specialization optimized for the single-value case, but keyed by integer position instead of label. Accessing position (0, 1) with iat[] retrieves the value at the first row and second column by pure position, ignoring whatever labels the index and columns actually carry, the same positional semantics as iloc[] but restricted to a single cell for better performance.
1Understanding df.iat[]
iat[] is to iloc[] exactly what at[] is to loc[]: a scalar-only specialization optimized for the single-value case, but keyed by integer position instead of label. Accessing position (0, 1) with iat[] retrieves the value at the first row and second column by pure position, ignoring whatever labels the index and columns actually carry, the same positional semantics as iloc[] but restricted to a single cell for better performance.
Reach for iat[] over iloc[] specifically when you're getting or setting exactly one scalar value by position — the same performance reasoning that favors at[] over loc[] for the label-based case.
import pandas as pd
df = pd.DataFrame({"a": [1, 2, 3], "b": [4, 5, 6]})
print(df.iat[1, 1])2Practical Example
Here is a real-world application of df.iat[] showing how it is used in production Pandas code.
import pandas as pd
df = pd.DataFrame({"a": [1, 2, 3], "b": [4, 5, 6]})
df.iat[0, 0] = 99
print(df)3Best Practices
Follow these guidelines when working with df.iat[]:
1. Use iat[] instead of iloc[] for single-scalar positional access/assignment when performance matters, such as inside a loop
2. Use iloc[] instead when you might select more than a single value, a whole row, column, or range, by position
3. Use at[] instead of iat[] when accessing by label rather than by integer position
Tip: Reach for iat[] over iloc[] specifically when you're getting or setting exactly one scalar value by position — the same performance reasoning that favors at[] over loc[] for the label-based case.
import pandas as pd
df = pd.DataFrame({"a": [1, 2, 3], "b": [4, 5, 6]})
print(df.iat[1, 1])