In this article, we will see what is iloc.
iloc is a method in Pandas.
Pandas is an helpful package for importing and analyzing data. Pandas provide a unique method to retrive rows from a Data frame.
Dataframe.iloc is a method used when the index label of data frame is integer position based (from 0 to length-1 of the axis), but may also be used with a boolean array.
- #Extracting single row
import pandas as pd data = pd.read_csv("Students.csv") row1 = data.iloc print(row1)
Name CHRISTY Age 20 Grade A Name: 2, dtype: object
- #Extracting multiple rows with index
import pandas as pd data = pd.read_csv("Students.csv") row1 = data.iloc[1:4] print(row1)
Name Age Grade 1 BINDU 21 A 2 CHRISTY 20 A 3 YOUSUF 21 A