w3resource

Pandas Series property: iat

Access a single value for a row/column pair in Pandas

The iat property is used to access a single value for a row/column pair by integer position.

Similar to iloc, in that both provide integer-based lookups. Use iat if you only need to get or set a single value in a DataFrame or Series.

Syntax:

Series.iat
Pandas Series iat property

Raises: IndexError
When integer position is out of bounds

Example:

Python-Pandas Code:

import numpy as np
import pandas as pd
df = pd.DataFrame([[2, 3, 4], [0, 5, 6], [20, 30, 40]],
                  columns=['P', 'Q', 'R'])
df

Output:

    P	Q	R
0	2	3	4
1	0	5	6
2	20	30	40
Pandas Series iat property

Example - Get value at specified row/column pair:

Python-Pandas Code:

import numpy as np
import pandas as pd
df = pd.DataFrame([[2, 3, 4], [0, 5, 6], [20, 30, 40]],
                  columns=['P', 'Q', 'R'])
df.iat[2, 2]

Output:

40

Example - Set value at specified row/column pair:

Python-Pandas Code:

import numpy as np
import pandas as pd
df = pd.DataFrame([[2, 3, 4], [0, 5, 6], [20, 30, 40]],
                  columns=['P', 'Q', 'R'])
df.iat[2, 2] = 10
df.iat[2, 2]

Output:

10

Example - Get value within a series:

Python-Pandas Code:

import numpy as np
import pandas as pd
df = pd.DataFrame([[2, 3, 4], [0, 5, 6], [20, 30, 40]],
                  columns=['P', 'Q', 'R'])
df.iat[2, 2] = 10
df.loc[0].iat[2]

Output:

4
Pandas Series iat property

Previous: Access a single value for a row/column label pair in Pandas
Next: Access a group of rows and columns in Pandas



Become a Patron!

Follow us on Facebook and Twitter for latest update.

It will be nice if you may share this link in any developer community or anywhere else, from where other developers may find this content. Thanks.

https://www.w3resource.com/pandas/series/series-iat.php