How to Slice DataFrame 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.head(3))
#print(df.tail(3))
#print(df.columns)
# #print(df[['empname','totalsalary']])
# print(df[1:11:2])
 #[start:stop:step]
print(df[['empname','totalsalary']][1:11])

 

Did we exceed your expectations?
If Yes, share your valuable feedback on Google

follow dataflair on YouTube

Leave a Reply

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