How to Apply Filter in Pandas
Get Job-Ready: Data Analysis using Python with 70+ Projects Start Now!!
Program 1
# Filter in Python
import pandas as pd
myfile="D://mypandas/employee2.xlsx"
df=pd.read_excel(myfile)
#print(df.loc[(df['totalsalary']>10000)])
# and & or | not ~
#print(df.loc[(df['gender']=='male') & (df['totalsalary']>10000)])
#print(df.loc[(df['empdept']=='CS') & (df['gender']=='female')])
#print(df.loc[(df['empname'].str.contains('A')) | (df['empname'].str.contains('a'))])
#print(df.loc[(df['empname'].str.startswith('Raj'))])
#print(df.loc[~(df['totalsalary']>10000)])
We work very hard to provide you quality material
Could you take 15 seconds and share your happy experience on Google

