S.
Name of the Experiment
Page Date of Date of Remarks
No. No. Experiment Submission
J. To print pandas sexies 27 O 02
trom dict and mdaray
2. To print elements above 2 310t022
15 percentile in sezies
3. Create Data Fxane 3 |St Nov 2012
quax texy sales
y. Creats ta Fxame tor 3rd
exammeSts
5. To FilteY Out duplicate 5 stNovo
6. Sn poxting amd expoxtiig p"ov ho
csy he
1. Subject wiaL o las |0Novlm2
wise dáta visuali zatim
8. To plot charts a 8
lugendo
9. Wis sQL querries based 2 Dec|02L
0n qiven table
In d e X
S.
Nameof the Experiment Page Date of Date of
No.
No. Experiment Submission Remarks
To wte sqL quesries 12 JDec J2022
based 0n qiven melation
import pandas as pd
#1(a) ->Series from DËctionary
:78,'Parul':73, 'Rahul':90}
Students1 = {'Ankit!
Series1 = pd.Series(Students1)
print (Series1)
Ankit 78
Parul 73
Rahul 90
dtype: intb4
#1(b)->Series from Ndarray
import nümpy as np
array1= np.array ([78, 73, 901)
Series2 =pd.Series(array1)
print (Series2)
78
1 73
2 90
dtype: int32
Date
Page No. 4
Expt. No.
Data Hamalg
do aeate a panclas seeies om a ditionauy
om
ndaiay
Soukce Coce
>Sexia om biliony
impontpandas a pd
Sed = pd. Sexieal Skudantai
pnt (Sud1)
Impokt paaadas AD pd
impout numby y (C16,13,90)
ahayz npanay
SexlE pd Sauiea Laxray1)
pmt
Teacher's Signature
percentile
Series, print all the elements that are above 75
#2->6iven a
test = pd.Series([2, 5, 4, 6, 8, 3, 10, 23])
percentile =test.quantile(.75)
print("75th Percentile is ',percentile)
Percentile are:)
print(The value that are above 75th
for x in range (len(test) ):
if test [x]>percentile:
print (test [x]).
75th Percentile is 8.5
The valLue that are above 75th Percentile are:
10
23
Date
Expt. No. 2 Page No.
Am GuiLw a punt alhe le nent that
the 1G th
5Eln peLLentile
Sowrce Code
Teat - pd. Sexierl25,4,6,8,3,1o, 231)
Pexcentile Teat,quaatileLl5)
Dvint °15th le(entlas Pexcent
phnt he alus that ae Ahouethe 1sth Pescentil a u ; )
lenal Teat)):
Teacher's Signature
3->Create a DataFrame Qvarterly sales where each roW
1tem name, and expenditure, Group the rows by contains the item category,
per category category and print the total expenditure
quarterly_sales {Item Category:['Cold 0ink, 'Chips Chocolate
'Item
'Chips,Cold Drink'17
Name':[Coke', Lays Dairy MiLK
KUrkure,Fanta'J,
'Expenditure: [35, 20, 40, 20, 65])}
df_sales = pd.DataFrame
print (df_sales) (quarterly_sales)
print (df_sales.groupby(Item
Category')Expenditure J.sum0).
Item Category Item Name
Cold Drink
Expenditure
Coke 35
1
Chips Lays 20
2
Chocolate Dairy Milk 40
3
Chips Kurkure 20
4 Cold Drink Fanta 65
Item CategorY
Chips 40
Chocolate 40
Cold Drink 100
Name: Expenditure, dtype: int64,
Signature Teacher's
ldsals.
liem gopby koSala. at
m)
Bame pd.ata chsales=
lquatexly
salea)
20,40,20,65]
(
ysDWy Name Iten
Mak chips""
"Chooldi
quartexly-Aalea=
DHimk
"] cold Item
nkChips "old (alegsry pandascs
ed impox
Code Saue
expeAnditue the pnt
totalexpendlitu
categy pie
the GDup e
ategsy he by Ows
categy Lem the
ad name, item Data
brame
hwe sls quately
ach No. Expt.
3
No. Page
3
Date
diplay row, labels, column labels
->Create a DataFrame for Exanination Result and
datatypes of each colunn: and the dinensions
exam_data [(1234, 'Ankit', 460, 92.0, 'A),
(1235, Rahul', 400, 80.0, 'A'),
(1236, 'Pankaj', 385, 77.0, 'B'),
(1237, Jatin', 462, 92.4, 'A'),
(1238, Guddu', 280, 56.0, C)]
Total
exan_result pd.DataFrame (exan_data, coluans=AdaNo"Nane"
Percentage Grade 1)
print (exan_result)
print( Caluna labels are')
prìnt (exan_result.coluans)
print(' Row labels are')
prìnt(exam_result.index.valves)
print("Datatype of colunns are")
print (exam_result.dtypes)
prìnt(Dìncensions of DataFraae are )
print (exam_ result. shape)
Name:ExpenditUre, dtype: intb4
AdmNo Name Total Percentage Grade
92.0 A+
Ankit 460
1234
400 80.0
1 1235 Rahul
1236 Pankaj 385 77.0
2
Jatin 462 9254
3 1237
1238*GUddu 280 56.0
Date
Page No.
Expt. No. 4
DataErane for xaminaion J s t amd
Aim o Creati a types af each
iapla wwslabela, c o l n labls daa
calunn a d tleclimemoien
SKure cede
imest paadas as pd "),
exam-date CU234, Ankit", y60 q 0 A+
(1235 Paya,400,80,0,A")
(1236 Rah", 385 110, B')
(l231 , Acyuah" uE242,4A")
(1238,4a ketun' 290 56.D""T
(eXAmdata colunn Admno
DxamnLit = pd, Datafrone
"NarAe Tota "Per centa qe hade')
peiat l e x a m l
LRuintaxan reut, colmn)
pimt Row Labdsane ")
Dnt (exam-et. indux, uals
pat e x a m t , dkyps
peuat himunsim al Datarame ae")
Teacher's Signature
#5->Filter =out rows based on
Students2 [(Jack', 34, different criteria such as
((Jonas' 16, 'Sydney'
New
), ((Ritu! dublicate rows
30, 'Delhi')
(RitU!, 30, York'), ('Ritu, 30, Delhi')
Data = ((Jonas' ,316, Delhi'), (Ritu', 30, Delhi' ),
New York),
(Akash, 30, Delhi),]
pd.DataFrame (Students2, Golumns=[Name
print (Data) Age City'])
Duplicate_Rows = Data[Data.duplicated O1
print('
print D uplicate Rows are: )
(Duplicate_Rows)
Date
Expt. No. 5 Page No. 5
S9UcL cede
imor parndas cs pd
to2 =["Tak",34,sydasy " "'Rut3o,"Deshi),
CAadi16,Nw VoJ "),Riti3O,"Dehi ")
'Rat",30,blhi"),Rit"30, Mumbai),
("Aadi 40, Lomdon" ) ( sachia' 30,"Deshi")l
bata = pd. DataExane ( Student,2, colnne fNasm"Aye, cty
pnt Data)
Dupicataeous F Datalbata, dupticatud )1
Teacher's Signature
#6->Importing & Exporting data b/w Pandas and CSV file
#IMPORTING
df = pd.read_csv("C:\\Users\geniu\\Downloads\\book1.csv"
encoding='latin1
nanes=['Name', Class Rno
Marks!])
print (df)
#EXPORTING
df = pd. DataFrame
({Name:Jonas Martha Hanna
CLass:I12, 12, 12],
Marks:[69, 96, 4211)
print (df)
df.to_csv("C:\\Users\\geniU\ \Downloads\\baok2.csv")
Name Class Marks
Jonas 12 69
1 Martha 12 96
2 Hanna 12 42
A B C D L
1 Jonas XI1 18 80
2 Martha XII 15 90
Enid XII 6 78
4 Tyler XI 17 38
5 Bryce XII 3 69
A C D
1 Name Class Marks
0 Jonas 12 69
3 1 Martha 12 96
4 2Hanna 12 42
5
Date
Expt. No. Page No. 6
betwen pandas
Afm? tmpoxting and xpwctíng data batus
Sowce ced
Ampoktung
impext pasndaw as pd
Ra' Mak1)
’ #Exposhng
impoxt pamda as pd
Mauki':C 31, (9,91
de.to cs (Lotentl BookD,csy")
Teacher's Signature
imnort pandas as pd
import matplot lib.pyplot as plt "Mathematics","Biolocy","Ip"]
subject|"Phy<ics","Chemistry",
marks=[80,75, 70, 78,82] marker=""")
plt.plot (sub ject, marks,"r",
plt.title( "Marks scored")
plt.xlabel ("SUB)ECT")
plt.ylabecl ("MARKS")
plt. show()
Marks scored
80
MARKS
Physics Chemistry Mathematics Biology IP
UBJECT
Date
Expt. No. 4
Page No.
Visualizatien
Aim Cicn lhe ochool Leet data analae
dilernt paamoter, eg
byectLaeor cla ioL
impott malpluttib pypot as plt
manto C86,15 10,18,81
mankeu" ")
Rt. xlablSUBTECT")
pit yeabel " MARKS")
pltshDwl)
Teacher's Signature
import pandas as pd
import matplot lib.pyplot as plt
"BiolOy* M.
data ("RollNO:(11,12, 13,14,15],"subject":["physics", "chemi stry","Mat hemat ics",
"Narks":[80, 75, 70, 78, 82]}
df=pd.DataFrame (data)
df .plot(kind="hist")
plt. title("Marks scored")
plt.xlabel("sUBJECI")
plt.ylabel("NARKS")
plt.show()
Marks scored
RolINo
Marks
10 X 50 60 70
SJBJECT
Date
Expt. No. 2 Page No.
Am or the dataxams Ucattd ma amd plat
ahDale chata th lite and egenda
Sowtce cede
impctpamdas as pd
inpox naatplahb. pyplnt cs plt
data <d"Ralel'u,12,13, 14, S
Subjectphyischemisty',"Mathemahid, Bicloau
Maks':(80,15,16,18, 82]
d =pd. DataEranmaldata)
dl plet (hiad hiat]
plt. titlel'Maks seoud")
Rltylabu"MARKS)
Rtshow)
pltplotlk'nd = bax")
pltshw)
Teacher's Signature
ql>my
abase
anged Use mysql>
QueryOK,
mysql>
create
1
udents; row
database
affected
stream
(0.02
of_students;
sec)
Date
Expt. No. Page No.
Data Momagement
Que Consider the ollowing tables Student and Stream jn the
Streams-0_shuderto database.Ihe primnary key o Hhe
steam table is stCode wnich in the toreign kuy in the student
table. Ihe po0Ynaty ky6} the student table n Admo.
AdmNo Name Stcode
21| Jcuy NULL
SO3
241 Adatya
Sol
Dìkcha
333 Jasquh
356 Vedika
380 Aslapent S03
Stiode Stxeam
Sqence
commere
Soz Humamitis
wite sQL quenies fon the tolloung
Aim
(a) eeati Hhe database Stheama 0_ctudento
Souxc ode
beat databas sbeamas sfsudnta,
6)that the tahls Student ay chooimq appopatu Aala tyfeo
based th giun datan thtahle
Teacher's Signature
mysql> create table students
-> (AdmNo int Primary Key,
-> Name varchar(20),
-> StCode char(3));
Query 0K, O rows affected (0.04 sec)
mysql> update students
set StCode SO3
-> where Name= Jay;
Query OK, 1row affected (0.00 sec)
Rows matched: 1 Changed: 1 Warnings: 0
mysql> select name from students
where name like %a
-> order by name;
name
| Aditya |
| Dikstha |
Vedika
3 rows in set (0.00 sec)
mysql> select count(*), StCode from Students
-> group by Stode having count (StCode)>1;
count (*) |StCode |
3 SO3
2 | S01
2 rows in set (0. 01 isec)
Date
Expt. No. Page No.
Sowce codle
Crealetable tudnt
(Admlo nt Pinay ky
Namne Warcnl20)
Stode can3))
9 ay has now chamged his steam to Humamtis. Wit
appuopate sglq y to tlet this chanaqe.
updat Atudeht
wlae Name Iay'
La)usplay tha nams a Atudnts hAe namis end iththe
charastu 'a. Anang. ttheahudno m alphabethcel adu
SsunseCode
Sulect m a n e mAkudent
e) iot t e nmhe al atudntom each theam haning
than na studant
tem tdent
Gueup by stde haug cout (St Code)21i
Teacher's Signature
6 mysql>
rowS Aditya Vedika
DikshaAshpreet
JayJasqueen | name
->
in order
select
Set
by
(0.00 name
AdmNo
sec) from
desc
students
Date
Expt. No.
Page No.
Dis plauy the names af atudto olled in ditternt ateamns,
he atudhts are aManqd in dscemding aden af adissto
mmbe.
Sleet nae om Akudent
Oxder ky Adn No Desc
Teacher's Signature
product
mysql> create table
-> (PCode varchar(15),
-> PName varchar(20),
-> UPrice varchar(10),
);
-> Manufacturer varchar(30)
(0.03 sec)
Query OK, 0 rows affected
mysql>insert into product values
"Surf'),
-> ('PO1', 'Washing Powder', 120,
-> ('PO2', 'Tooth Paste', 54, 'Colgate'),
-> ('PO3', 'Soap', 25, 'Lux),
->((P04 'Tooth Paste', 65, 'Pepsodent'),
-> ('PO5', 'Soap', 38, " Dove"),
-> ('P06', 'Shampoo, 245, 'Dove');
Query OK, 6 rOws affected (0.01 sec)
Records : 6 Duplicates: 0 Warnings: 0
mysql>select PCode, PName, UPrice from Product
-> order by UPrice desC;
| PCode | PName | UPrice
PB4 Tooth Paste |65
PO2 Tooth Paste 54
PØ5
PO3
Soap I38
Soap
PO6 | 25
PO1 Shampoo 245
Washing Powder 120
6 rows in set (0.00
sec)