NUMPY Basics: Computation and File I/O Using Arrays
NUMPY Basics: Computation and File I/O Using Arrays
• Faster computations
• Broadcasting
• Sliceability
Basics in NumPy
Creating arrays Zeros and Ones Function
>>>from numpy as * >>>zeros((2,4))
>>>ones((3,3,3))
>>>a=array([[1,2,3],[4,5,6]])
>>>a
>>>a.shape() Diagonal Matrix
>>>d=diag([2,4,5])
Creating one-Dimensional Space
>>>b=arange(0,11)
>>>c=arange(0,2.0,0.4)
>>>d=linspace(0,3.5,8)
Use as array.attribute
Attribute Output
shape tuple showing the array shape; setting this at- tribute re-shapes the array
strides tuple showing how many bytes must be jumped in the data segment to get from
one entry to the next