Numpy Notes Csai
Numpy Notes Csai
Avruy
1-, Nesked ists a Omyn-dimumduéns a
S4 -D
Supports ana matnuuatia
Doesn+ Suppot mathuafia)
uuhioms
4untions
ist lt 3.910|e9. np arroul[, 1)
+
np.anay(T3,97)
t i t (,)+
[1, 2,3,9] Oay (L 4, u)
PRIORITY LIST
inme aud
3 Tajeey mone String Pront
6 pale .Ploot
int
import numpy a P
neotinq amay Bocfeunalo
xnp-amay [i, 4,F1) mvnty
Pint(x) [i,4,T1
Xshape (3,)opie
PF 1 1 0) ~Drimeuuions
X. ndim
RetunUeu{henen
Ommu
ARANGt 2
Print y)
L,1,5.1, 5,6,7,8,9)
X:np drange(1,
10, 2)
print ( ) - [,3,,7,9]
Stopping Poin, Attstep, & num)
no Numbers
Linspace (Sorting foint,
ne ced an Opthonal
nee isany t e n A Oant
5)
0 np. inspate (t, 10, retstp- Tue, num
bek n42.3-
ormay l[1. AnD-2no.3) m.4 1o.)J). dibo
Wanf amy (L1,2,4.5])
Teros b Ones w
[1.11, L[,2,
.,1.1, [3,41,
T.,1.1) [s,63
o n P : zeros-ike W)
RAND OM ariy [o.,0., 0.J)
(313))
random Size
=
random.
n array ( [ L K a n gw
p.random randint ( 5, 50, 6
hhis i l l hu 6 rondom inHa
- betwen 5 to 9.
-11)
arrauy (L 5,1, 38,u1, 23, 431)
Similar to randint,
np
random randint (5.50, [1,37)
randn will fie
array L[ s 16, 20o3,
T4,19, 3811)
yte:2]
array( 61,, 7,
2, 8,
3, 9, 10]1
1e]])
array([[ 1, 2].
6 , 7]
[11, 11]])
array(1
[6,
47, 8, 9,
9,
51.
1011)
10]1)
y fe, 2]1
->alL rows
array(I 1, 3
6, 8]1
[11, 11]])
a y[:, 0:3]
print(a)
print()
b y[: [e, 3]]
print (b)
1 2 3
6 7 8]
[11 11 11]]
I[ 1 4]
6 9]
[11 11]]
SEED
rondom.3ted ( 2) Runit Seuwa/ +tim, Qutfrut wil te
1P.
np rondom.randint i,10o)
o
w econ the id. Tndex
mumeer
INDEX 0 1
n-dimimAiona urray
np.argdorttx)
array ([, 5,0,,2,31 Let on avray y, dutu that
Re shape y.shape, (4,6)
no ()
9. reshape (no 0 , no. r
roud
Coum
Surh thut xc 4 X6
row mumbers
Bhoubod * Some wnneth mn wue
dor hstalk a
hstatk
oneatenatr, axís 1
y
array([[ 1, 2, 3, 4, 5, 6]
[4, 6, 7, 8 , 9, 10],
[11, 11, 11, 11, 11, 11].
1, 1, 1, 1, 1, 1]])
array([[ 1, 2,
array([[ 1, 3,
2, 5, 6].
[ 4, 6, 7, 8, 9, 10].
[11, 11, 11, 11, 11, 11]1
[1, 1, 1, 1, 1, 1.
[1, 2, 3, 4 5, 6],
[ 4, 6, 7, 8, 9, 10),
[10, 10, 10, 10, 1e, 18],
2 , 2, 2, 2, 2, 2]1)
np.hstack ((y, z))
array ([[ 1, 2, 3, 4, 5, 6, 1, 2, 3, 4, 5, 6].
[ 4, 6, 7, 9, 10, 4, 5,
8, 7. 8, 9, 10],
[11, 11, 11, 11, 11, 11, 10, 10, 10, 10, 10, 10]
[ 1, 1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 2]1)