Change language

Python | Pandas Series.iat

|

Pandas Series — it is a one-dimensional array with axis labels. Tags do not have to be unique, but must be hashable. The object supports indexing based on integers and labels and provides many methods for performing index-related operations.

Series.iat Pandas Series.iat to one value for a row / column pair at an integer position.

Syntax: Series.iat

Parameter: None

Returns: return value at the specified location

Example # 1: Use the Series.iat attribute to return the value present at the specified location for a given Series object.

# import pandas as pd

import pandas as pd

 
# Create series

sr = pd.Series ([ ’New York’ , ’ Chicago’ , ’Toronto’ , ’ Lisbon’ ])

 
# Create row axis labels

sr.index = [ ’City 1’ , ’ City 2’ , ’City 3’ , ’ City 4’

 
# Print series

print (sr)

Output:

Now we will use the Series.iat to return the value at index 0.

# return value at 0th index

sr.iat [ 0 ]

Output:

As we can see in the output, the Series.iat attribute returned & # 39; New York & # 39; which is the value present at index 0 in this Series object.

Example # 2: Use the Series.iat attribute to return a value, present at the specified location for this Series object.

# import pandas as pd

import pandas as pd

 
# Create series

sr = pd.Series ([ ’1/1 / 2018’ , ’2/1 / 2018’ , ’ 3/1 / 2018’ , ’4/1 / 2018’ ])

 
# Create row axis labels

sr.index = [ ’Day 1’ , ’ Day 2’ , ’Day 3’ , ’ Day 4’ ]

 
# Print series

print (sr)

Output:

Now we will use the Series.iat attribute to return the value at the second index.

# return value at 2nd index

sr.iat [ 2 ]

< p>

Output:


As we can see from the output, the Series.iat attribute returned "3/1/2018", which is the value present at the second index in this Series object.

Shop

Learn programming in R: courses

$

Best Python online courses for 2022

$

Best laptop for Fortnite

$

Best laptop for Excel

$

Best laptop for Solidworks

$

Best laptop for Roblox

$

Best computer for crypto mining

$

Best laptop for Sims 4

$

Latest questions

NUMPYNUMPY

psycopg2: insert multiple rows with one query

12 answers

NUMPYNUMPY

How to convert Nonetype to int or string?

12 answers

NUMPYNUMPY

How to specify multiple return types using type-hints

12 answers

NUMPYNUMPY

Javascript Error: IPython is not defined in JupyterLab

12 answers

News


Wiki

Python OpenCV | cv2.putText () method

numpy.arctan2 () in Python

Python | os.path.realpath () method

Python OpenCV | cv2.circle () method

Python OpenCV cv2.cvtColor () method

Python - Move item to the end of the list

time.perf_counter () function in Python

Check if one list is a subset of another in Python

Python os.path.join () method