W3docs

How can I get a value from a cell of a dataframe?

You can use the .at or .iat methods to get the value of a specific cell in a DataFrame.

You can use the .at or .iat methods to get the value of a specific cell in a DataFrame.

Here's an example:

Get a value from a cell of a Pandas DataFrame in Python using the at method

import pandas as pd

# Create a sample DataFrame
df = pd.DataFrame({'A': [1, 2, 3], 'B': [4, 5, 6], 'C': [7, 8, 9]})

# Get the value of the cell at row 0 and column 'A'
value = df.at[0, 'A']
print(value)

<div class="alert alert-info flex not-prose"> Watch a course <span class="hidden md:block">Watch a video course </span> Python - The Practical Guide</div>

You can also use the .iat method if you want to access the cell by its index rather than by its label:

Get a value from a cell of a Pandas DataFrame in Python using the iat method

value = df.iat[0, 0]
print(value)

Both .at and .iat will return the value of the cell at the specified row and column.