Skip to content
Justice Tech School

Fast Scalar Access

at and iat read or write a single cell quickly, by label or position.

Example
import pandas as pd
import numpy as np
df = pd.DataFrame({'name': ['Ada', 'Bob', 'Cy', 'Di'], 'age': [30, 25, 35, 28], 'city': ['Lagos', 'Accra', 'Lagos', 'Nairobi'], 'score': [88.5, 92.0, 79.5, 85.0]})
df.at[0, 'score'] = 90.0
print(df.at[0, 'score'], df.iat[1, 1])

Result

90.0 25

Exercise

Read one cell by label.

df.[0, "age"]

Quiz Test

Which accesses a single cell?

These free lessons are for learning. Join a full course for projects, mentor feedback and a verified certificate.