practical file class xii
practical file class xii
15 percentile in sezies
8. To plot charts a 8
lugendo
Ankit 78
Parul 73
Rahul 90
dtype: intb4
78
1 73
2 90
dtype: int32
Date
Page No. 4
Expt. No.
Data Hamalg
Soukce Coce
>Sexia om biliony
impontpandas a pd
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]).
Sowrce Code
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).
Page No.
Expt. No. 4
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
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
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
betwen pandas
Afm? tmpoxting and xpwctíng data batus
Sowce ced
Ampoktung
impext pasndaw as pd
Ra' Mak1)
’ #Exposhng
impoxt pamda as pd
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
Expt. No. 4
Page No.
Visualizatien
Aim Cicn lhe ochool Leet data analae
dilernt paamoter, eg
byectLaeor cla ioL
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
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
Stiode Stxeam
Sqence
commere
Soz Humamitis
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)
name
| Aditya |
| Dikstha |
Vedika
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
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.
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