Difference Between loc and iloc in Pandas

Free Pandas course with real-time projects Start Now!!

Program 1

import pandas as pd
df=pd.read_excel("E://mypandas/employee.xlsx")
# print(df)
# print("---------------------------------------------")
# print(df.loc[3,['empname','totalsalary']])
# print(df.loc[1:5,'empname':'totalsalary'])
print("---------------------------------------------")
print(df.iloc[:,1:4])

 

Your 15 seconds will encourage us to work even harder
Please share your happy experience on Google

follow dataflair on YouTube

Leave a Reply

Your email address will not be published. Required fields are marked *