Single Cells: at and iat
at and iat read one single cell. at uses labels, and iat uses positions.
at reads by label
The Tuesday row and the units column hold 1.
import pandas as pd
df = pd.DataFrame({
"product": ["Tea", "Coffee", "Mug"],
"units": [2, 1, 3],
}, index=["Mon", "Tue", "Wed"])
print(df.at["Tue", "units"])iat reads by position
Row 1 and column 1 hold the same value, 1.
import pandas as pd
df = pd.DataFrame({
"product": ["Tea", "Coffee", "Mug"],
"units": [2, 1, 3],
}, index=["Mon", "Tue", "Wed"])
print(df.iat[1, 1])Change one cell with at
at with an equals sign writes 5 into the Tuesday units cell.
import pandas as pd
df = pd.DataFrame({
"product": ["Tea", "Coffee", "Mug"],
"units": [2, 1, 3],
}, index=["Mon", "Tue", "Wed"])
df.at["Tue", "units"] = 5
print(df)Example
import io
import pandas as pd
SALES_CSV = """order_id,date,product,category,units,price,region
101,2026-01-05,Tea,Drink,2,4.50,North
102,2026-01-06,Coffee,Drink,1,6.00,South
103,2026-01-07,Mug,Home,3,12.00,East
104,2026-01-08,Notebook,Office,2,8.50,West
105,2026-01-09,Pen,Office,5,2.00,North
106,2026-01-12,Lamp,Home,1,24.00,South
107,2026-01-13,Tea,Drink,4,4.50,East
108,2026-01-14,Coffee,Drink,2,6.00,West
109,2026-01-15,Mug,Home,1,12.00,North
110,2026-01-16,Notebook,Office,3,8.50,South
111,2026-01-19,Pen,Office,2,2.00,East
112,2026-01-20,Lamp,Home,2,24.00,West"""
sales = pd.read_csv(io.StringIO(SALES_CSV))
print(sales.at[3, "product"])
print(sales.iat[3, 2])Key points
- Use at with a row label and a column name.
- Use iat with a row position and a column position.
- Both return one single value, not a row or a table.
- at also writes one cell, with an equals sign.
- Use at and iat for one cell, and loc and iloc for rows and tables.
In this example, the sales table is read from the CSV text. at reads row 3 by label and the product column by name. iat reads the same cell by row position 3 and column position 2. Both give Notebook.
Try it Yourself
Edit the code, then press Run.
Running is simulated · Python Playground
Exercise
Which code reads the value at row label "Tue" and column "units"?