0 ratings0% found this document useful (0 votes) 68 views6 pagesPython Assignment 2
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content,
claim it here.
Available Formats
Download as PDF or read online on Scribd
Assignment-2
BA=I Cpythor Reeavuasy,
A
Write an example program ‘to add -the tHe to the chart different
font size,colour and also assign X and ¥ axts label for chart?
tn) = import matplotitb: pyplot oS ple
x=f35r)
y= (26810)
ple-plot Cs yto*-—!, morkersize= \o-5 linewidth=25)
pit-itle (‘sample_ chor’)
pre-show ( )
-s if the usey want to 0ssign she tite with different font-size and
colour
~pwe can access the font-size ¢ colos In dite fanction
pit tite (‘samplechott, font-size =80, color -\green’)
plt-show (}
-o\t the user want to assign X and ¥ axts on chast, we can use
late) to assess the cordtnates on chart:
plt-xtabel c y-oxts)
ple Ylabel (y-axis)
ple-shoud }
Define numerical package i python and explain how to install
Numpy? wite an example Program 4p print & numbers by using
snumpy and algo write example prog7am an zero dtmenstonal and
a-dimenstonal anway?
Numesiea) package 10 rethonst
he entive concept tn “the form of anays © extrac the numbexs
22.06:
Sec-c CRInan
xv=
D| write an ex
tena this ‘Should be used th the-form of analytical
as pert ‘index’ cri
the ‘data. with the hejp of, Index number:
"yeseoxch “en ext¥ac
>To extract the fouls and columns fh 2D arrays -
+To print S numbers by using numpy
NCD + Imports Numpy a5 TP
con's npramay (8,209)
print (a)
output? [P23 ust |
+o print zero dimensional 27709
ial) + import numpy 45 “Pp ‘
mre praca (5)
print: (am)
output? &
To pane 2 med
in(3 ore ump 05 TF
ont = npravod (tue,
print: (arr)
output / G12 33
Lose)
c71e4
ome. prearam “P
sate)
extrack -the gf elemest from arr orrval)
\nl)4 enpor numpy 99 np
aon 2np atoy (C124) uS)
paint (arr (23)9
9
Example
ple program to print 50 numbers by using avangeC
eC) function-
InU) + Import aumpy as 9P
ony = Np-avange (Sd)
print (ar)
cutput + [Ort sarph-s5e6s7 8 4 10 =~ aq]
Example Prooram to print So numbers with = records|sets and 5
qouss, Vcolurnns
inl) +import NUMpPY as np
any = Np: arrange (SO): reshape (55)
print (art)
output L fo)
(233
Cae ud)
pefine ‘Inter changing of Rows and columns ?
fo get tows (nto @lurans and
we have to use te ‘transpwe
co\usnns Tinto OWS
we have to Use ae
nO: oa T
(a)
os)
(368)
ouspur? OODefine pandas? How +o install pandos?7 write an example program -to
create a series ‘and also to crette index values +o Series?
data library 2 analyse the data from extemal files
andes & &
ev (lab seperated valu) and also data scraping
Vike -yesw "O52
fom web powed - pandas vill) @nalyse manually loaded data or
trading data
eaTrere are 2 data types 1) Serfes obect
22) Data-fiame object
Seviest
Series & ONE dimensional object simtlar %o bullet phyton list -
ta. frame -
“sax i a datatype tat represents each column of da:
4o Ist concept Each element must be same dlatettype
and © Stiilax
Nolet
5 Sevies and dataframes ave 2 datatypes fot pandas:
5 so that we can analyse athe data to tentfy the 92
exbact single Column § single vou data
oltse the dain by using pandas 9S +
lib on pandas “or visualtsation ©
of Yous and
columns to
per requirement §
swe can visu
we can use matplo’
raw to instal) pandas
nO PIP install pandas
eote A series
jas as pa
anancé)
2To Cf
Ants tmport Pang
aspaseries (Les
print (a)
: ° tol
outpe! finance
type + object3
~STe create Index values te sevies
las as pd
az parsertes ({ie! Minancé | index = fs ubjeck—
print (2)
tn) + Import pand. f
code 'ubject.rav)
subject_code {ol
finance
output *
subject name
d-cype tobfect
Example program 4o print the following output with 5 vous and
3 columns:
Int Import pandas 6° pd
ic epd: Data frame (flenane’ [fuer inte Sword] A000 #
Lge, 26,6), Now + tu 2,26,78)5)
print CX)
oukputt — came high Yow
sT et
Info 26 as
waipro cu 18
write an exemple program to exback the Index I data
inl)? Print (af loci)
ourpt ? CNome info
High Ee
low as
Nameid, dtype? obyeck
lay criteria as per Yequremer
Nolet “loc method wil) extract che partic
ttfollowing dataset:
Year ‘employment skills
2018 6\
2019 2
2020 90
2021 23
2022, 65
2028 24
2024 by
vrsualisationvsing pandast
and we can Slow he data as of requirement
chart aren i
_s by using date frome -the user an early access the charts, we @0
the data 05 per dataset on
dataset we create Index labels ch
KY ants labels on the same for this We co!
as seobon iS also available:
ato create dataset
sept create. a dato. Frome
etepi2> plot te chart
© Inc ztenpott pandas a5 pd
tmport mozplot I"b -Pupet as pt
data = f'yeor"? [aoe 2019,2020,2021 2022 2025), employent auetl't
£ 6a,ad.90, 03,65,24,600%4
fiz pa-datafome (data)
print 49)
® WO de 5
9 C0 + deeplot (x year! u=semplogrenk SkI8, Kind toca ther, Color re)
plt-showL)
10 Define visualisation using pandas an example program © th:
visualisati ndas? usrite
Prog: re
isualisationvoing_ pare
_>by using pandas we COP \igualtse the data ultth the hejp of matploHtt
wt mdividual Colors on
individual criteria OF sometimes enthre
arts and also we can create
yn use a new! libvary @lled
plot