How to Use SQL in Pandas

Get Job-Ready: Data Analysis using Python with 70+ Projects Start Now!!

Program 1

Pandas Dataset

import pandas as pd
emp=pd.read_excel("D://mypandas/employee.xlsx")
#print(emp.nlargest(5,columns='totalsalary'))
#print(emp.nlargest(5,columns='totalsalary').tail(4))
#Insert

# Update
# emp.loc[emp['totalsalary']==10000]=15000
# emp.loc[emp['totalsalary']==15000,'totalsalary']=25000
# print(emp)

#Delete
#emp=emp.drop(emp[emp.totalsalary==10000].index)
print(emp)









#print(emp.head(6))
#print(emp.tail(6))
#select * from employee where salary>10000;
#print(emp.columns)

#select * from employee where salary>10000 and edept='CS';
#print(emp[(emp.totalsalary>10000) & (emp.empdept>'CS')][['empname','totalsalary','empdept']])

#select * from employee where salary in(60000,70000,80000);
#print(emp[~emp.totalsalary.isin([7000,8000,12000])][['empname','totalsalary','empdept']])
#print(emp[(emp.empdept=='CS')|(emp.empdept=='IT')][['empname','totalsalary','empdept']])

 

Did you know we work 24x7 to provide you best tutorials
Please encourage us - write a review on Google

courses

DataFlair Team

DataFlair Team provides high-impact content on programming, Java, Python, C++, DSA, AI, ML, data Science, Android, Flutter, MERN, Web Development, and technology. We make complex concepts easy to grasp, helping learners of all levels succeed in their tech careers.

Leave a Reply

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