0% found this document useful (0 votes)
6 views11 pages

numpy

The document provides an overview of NumPy, a powerful library in Python for numerical computing. It covers various types of arrays, including 1-D, 2-D, and 3-D arrays, as well as operations such as creating, reshaping, and performing mathematical functions on these arrays. Additionally, it discusses array manipulation techniques like sorting, slicing, and statistical calculations.

Uploaded by

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

numpy

The document provides an overview of NumPy, a powerful library in Python for numerical computing. It covers various types of arrays, including 1-D, 2-D, and 3-D arrays, as well as operations such as creating, reshaping, and performing mathematical functions on these arrays. Additionally, it discusses array manipulation techniques like sorting, slicing, and statistical calculations.

Uploaded by

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

What is 11 2 3 4 5 6

NumPy 1-DNumPy Arrays

in Python? 1 2 3
1

4
2 3

5 6 7 8

10 11 12
2-D NumPy Arrays
3-D NumPy Arrays

www.educba.com
oyuteg:
np.aruayllanlia,3,4s)
pudlaC:1)#[o|27
ButQoD:)#l2345)
uoys
Put(aC::27)+[o24]

me fo nuny)
Nata
nomby as npCnpu had
te iiot

evenl =np ali23,45])


Roist(onl) # [2345
2PAroauyCipe Nasü)
asuy(r,2.37,C4.s.67])
coo2 np. CcI232.
t4561)
3 Anoy (ike alube)'
(ao3)
4+ CIt 21
puint

Prino2,ndim)+ No. o no(alun3D,eto


dimesibmsli
point (avon2-fhpe +fhape leet
Pint (oli3e#Tat No.
Qutput
+(2,3)2rowd 3(osomn»
H6= 6elee tota/
t int32 s9tig tye
Woay aZenosnp.Zo))
Zzmos =np.zeros(3,3) ys:)
pint( Zeo)+[[b,0.01
CO.0.o]
Co. 0. 0]J
VWay Cues:l np. Onel))
Gves np.onegCC2,4))
punt (One)+CEl.I1.11
Vaoy a Romdemmleo Cnp.rqndos.tandt )
rand-numt= np.Tanolomnd(?,2)
printrand-numrb.a324- o.2145]
to-8463 6.5392])

idemty- npeyec?)
Printlidenity)# LLI.0.D]
Dees oealu a [0.1.0]
0.0.13]

le

gel)
Start=l &toposte
1o,2)#
Secl= nP. asamylI,
shoced nmbo)
stop-o,Jtoþ=s
npinsfacel (euuny
) Ch,lD,<+stavt-l, 10. J
=np dinshace 5.5 17s
&eq2
pritSeq# . 3.25
liofaii)
)
.

Houp:2
Srderig nd Siuingy
accei he 3elen
import nomy s np
arrau(Cjo,o,30, I0, 5o])
arr= n p.
rint Cal2])tt 3D

airayI231,C45, 6],[7 12911)


artenp.
Prind l a 2 1 +

Print (avrC l; S1)A Lao 230 4o57

Caliugp:2,1:1 )t
np. median oy)
S])
qvô = nparrayCI,2,3,4
printnp.meay ar)t3.0
print Cnp.Std(avv))t soncdae deuah
Efoustia!
Prin (np.enpar) t E Rovt
(np-cgrtar))#dquaa
Prinl

hpng,1o).reshape C3.3)
cr
Print (arr)
rous lalmy
printarr.T)#wnpe

[3,)) hhorigontatl,
a= nparraycri,1,
5. 61,HS)
Ystock() b= np. array(
2 pintlnp- hatacpCCa b)))+[II256]
6)

(1te) tt Splh ính 3 equuel parts


aYt=np avange
print (np-spi (aw,3))#Canaylli2,3])
avran(CiSi8]),
Ovvag(C3197)]

ar2P=naitay(lLI, 2i3]Is,1))
arld =ari2D. la tt c)
pint Carrld)
+LI 2 3 45 6A8 9
Hour
Jatl:Nun,Qnoncecutang(Dydse
whut-b-0acashig: Yo plhaf.
imnport nemty as nf
nparay(lh2,31) 2 32 321)

PrintCa)
co natel

oetelyd3) hoibe)

Sudenina(dittg uuth lonalan


ltep2; Besleau
arrenp.arra yCCl0, 20, 30,uo56))
printlarrlarr >25])# o 4o 50] delitd.
*.anyc): ley a leaut eu Valer mety
u Caidii'
*ol ): ): leek

arr= n.av YaylT 4o,30,26])


print(np. Cort lar)) +10 a o#o 46]
Printlnpwhene Cavr=,= 3) ) tt (avray( [2)

ar np. array l213,3, 3,41)


print Cnp.Unitu(arr) +CI234]
*(ount Oocey
Print Cnp. bintoontCa))

Milhematicalaenalis
6teþl;_ Beosie
(uitl t
0mport numy as p 20, 30,4e])
ar|= np. ayroy(to, 4])
aYY2 =np.arrauCCI,213,
print(ar|tar)+ Ll22 33 447
orrt- rre)+[g 1 24 36]
Prirt 40 9o 1bo]
print avrl avr2 )+ L1o
Print avYl/ar2 o lo. Jo. 1o.]

JmctioyCumMib, Mar Nean)


vdola
ClY-np. anay (Cs,jo,S,2o2s1
pint(n.lucavy) +45 (sonm a al eemt)
(hp. miaard)} s( iallet nimbn)
print as(targt No. )
print (np. )#
maylay)
(Avag)
print (np. mean(ar))t 15.0
Print (np. median(a))+ 15.o (Midd Vale
printlnp.prodlavv))#3450vo (ergouut a

Vaiome (Var ): Meouulle


eo

np-avayClo 2o, 30 uo.5o])


Psint Cnp.varqvr) 200.0(vai g
(aylntiou wd (ovaoic
(Caoy latol(orr(oeh)
X- npanayCtli 2,3,451)
.
Col elatia=hp.correoe
Print (o\relation ) tve (onselotin(uenne

Houe:s Aohomceo Nimaty heatiand


Cteb|sating
(Yau fort)to ariange elennt in

ay np.avayCEojlo,5e2131)
Sortedar= n. sort lar!
Plnt(soYted_a)t Cjo 20 3o yo So
a2
anephp. cor
ayvay
fa(C221,C615,
6 1 5 , 1`)
0)
print (np.

t
cjrv=np. Orro(Ç lo,2p304o,S0])
ihceey npheu lorr >)

trint (np'aheu (aw Yo 2


=-0))# (onraglo);

enrt(ehapedar)# LEI 2 31
[45
ylattenl):
Print Coeshapoaroavell)) #ti2 3450

hstlch()

S þlit ) np. Spli(Vaniabit nany Sld


Houe:s iatio
nomdom cotatiM.
\mbot nmy daa )
Jarsearay= np. randomra ndC-00000)
pånt Uasngrra yCilol #airt t (o mo.

Vectonged henalis m
Jastiahon
ayrznp.arayCli2i3,4s7)
Sqvand. appendCnum*2)
prirt(sqUoyed ) 4,3l625]
S uared = a t
print (Sqvored)
(arri2 np-powey boeiali
np-multtply
2) (anl,np.divide( mutipolyin np.dvide(
) hp.subtract hp.multily)eleentwne
np.add(arrlh
ar2) Sorailo ng.subtratl)
Addiia np.addl)
OrrE2,:]
arl:4] (oluwei
arr2]
Slicg ond, 3.uten
avel()
(3,hatelay,
3) hp.e (1b) avay am tattenp.ravel()
Realapenp.rchapel)
ndim aY. no.
aYray-ndim
Red
Curr.Si aelement aWay-sige
ar.shape dnmendiom avy Rotuw
Rolnuo.sma array-shaþe
p.rondom. olHamdoyno.
) (o. qeenale, tandon.TandC )
np Cueatlinu spacaC) np.np.
arrg np. ringre uitha Aag eatValea arange) np.
eyela) oealiidenlity
wabs hp.egel)
) np oealiavy Lreales
)) ones np. Oney sal. illd led bpones)
np.zeros)
) Zeno utl np.avray)
np.aoy Dexuá bal metians
chevetial np- oxpCar)
Natwl Aagathm hp loglarr)
n.qttlar)
np. sinl ) n
np- Sinlarr)
g.(osl ) np.(os lau)
np.tanl)
ng. tanla)
np. sum() np Surar)
np. me an) MeaAvg) np. meanl axx)
np.median( ) Medi
np. min(0 Mmimm Valey nemedianhar)
np. minarr
hp. ma x Monimm Val np.may(o)
p. std()
np.vasl)
atlondae
Vaiom
ceatiom n-stdlar)
ng-vaylay )

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy