xxxxxxxxxx
iloc - default indexes (system generated)
loc - table indexes or we manually given indexes
iloc usage
xxxxxxxxxx
import pandas as pd
technologies = {
'Courses':["Spark","PySpark","Hadoop","Python","pandas"],
'Fee' :[20000,25000,26000,22000,24000],
'Duration':['30day','40days','35days','40days','60days'],
'Discount':[1000,2300,1200,2500,2000]
}
index_labels=['r1','r2','r3','r4','r5']
df = pd.DataFrame(technologies,index=index_labels)
print(df)
# Select Single Row by Index
print(df.iloc[1])
# Select Single Column by Index
print(df.iloc[:, 0])
# Select Multiple Rows by Index
print(df.iloc[[1,2]])
# Select Multiple Columns by Index
print(df.iloc[:, [0,1,3]])
# Includes Index 0 & Execludes 4
print(df.iloc[0:4])
# Includes Index 1 & Execludes 4
print(df.iloc[:,1:4])
# Select Alternate rows By Index
print(df.iloc[0:4:2])
# Select Alternate Columns between two Indexes
print(df.iloc[:,1:4:2])
print(df.iloc[list(df['Fee'] >= 24000)])