Python Part 3 - Scientific Python

Dave White

NumPy

pip install numpy
import numpy as np
A=np.array([[0,1,2,3,4],
         [5,6,7,8,9],
         [10,11,12,13,14]])
print(A)

A.shape
A.ndim
A.dtype.name
A.size
type(A)

B = np.arange(9).reshape(3, 3)
print(B)
B.shape

myvec=np.array([1, 2, 3, 4])
print(myvec)
myvec.size
myvec.shape # note second dimension is empty

myvec=np.array([1, 2, 3, 4],dtype=np.int8)

print(B)
B=B.reshape(1,9)
B.shape
B=B.reshape(9,)
B.shape

Z=np.zeros((3,4))
print(Z)
Z+1
A*0
A**2
A @ np.transpose(A)

A[0,]
A[0]
A[0:1,]
A[0:2,-1]

TODO