Site icon DataFlair

How to Slice DataFrame in Pandas

Get Job-Ready: Data Analysis using Python with 70+ 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])

 

Exit mobile version