0% found this document useful (0 votes)
2 views

class12

The document outlines SQL commands to create a database and a table for employee records, including inserting data and performing queries for average and maximum salaries. It also includes Python code for data manipulation using pandas, creating a DataFrame, adding new data, calculating totals, and visualizing the results with a bar chart. Finally, it demonstrates saving the DataFrame to a CSV file.

Uploaded by

surabhisharmamca
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
2 views

class12

The document outlines SQL commands to create a database and a table for employee records, including inserting data and performing queries for average and maximum salaries. It also includes Python code for data manipulation using pandas, creating a DataFrame, adding new data, calculating totals, and visualizing the results with a bar chart. Finally, it demonstrates saving the DataFrame to a CSV file.

Uploaded by

surabhisharmamca
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 1

1.

create database emp12;

use emp12;

2.create table employee(empid int(10) primary key, name varchar(20), department


varchar(20),salary int(10));

3.insert into employee values(1,"naresh","clerk",40000),(2, "ajay","manager",50000),


(3,"komal","clerk",60000),(4,"varun","admin",50000);

4.select avg(salary) , max(salary) from employee;

5.select ucase(name),lcase(department) from employee;

6. select department , count(*) from employee group by department;

7. alter table employee add new_salary int(10);

python

import pandas as pd

import matplotlib.pyplot as plt

dict1={'maths':[23,30,25,28],'science':[30,27,25,26],'english':[25,28,29,28],'ssc':[28,30,26,27]}

df=pd.DataFrame(dict1,index=['suraj','rahul','raju','pooja'])

print(df)

df.loc['shyam']=[26,28,28,27]

print(df)

df['total']=df['maths']+df['science']+df['english']+df['ssc']

print(df)

x=df.loc[['pooja','raju'],'maths']

print(x)

df.drop('pooja',axis=0,inplace=True)

print(df)

df.to_csv(path_or_buf='Book1.csv')

df.plot(kind="bar", color=['red','blue','pink','green'])

plt.xlabel("students")

plt.ylabel("marks")

plt.title("report")

plt.show()

You might also like