What is the iat method in pandas?

The iat method in pandas is used to get a single value from a dataframe based on the row and column index. The iat function needs two parameters: the row and column index.

It then returns the value of the specified index.

The illustration below shows how iat method works in pandas:

How does iat method work

Syntax

The syntax of the iat method is as follows:

Dataframe.iat[row, column]

Parameters

The iat method takes a row index and a column index.

Return value

The iat method returns the value at the corresponding row and column index.

Errors

An error is raised if the parameters passed as the row and column indexes are out of bounds or not present in the dataframe.

Example

The code snippet below shows how the iat method works in pandas:

We can also use the iat method to assign a value on a particular index. This is shown in line 14:

import pandas as pd
df = pd.DataFrame([[0, 2, 3], [0, 4, 1], [10, 20, 30]],
columns=['A', 'B', 'C'])
print("Original Dataframe")
print(df)
print('\n')
print("Get a value")
print(df.iat[1, 2])
print('\n')
df.iat[1, 2] = 10
print("New Dataframe")
print(df)

Free Resources

Copyright ©2025 Educative, Inc. All rights reserved