Professional Documents
Culture Documents
Cheat Sheet Numpy
Cheat Sheet Numpy
Documentation
my_mat = [[1,2,3],[4,5,6],[7,8,9]]
np.array np.array(my_mat)
Creates an array. Output:
3x3 array
Documentation
np.linspace(0, 1, 5)
Output:
np.linspace Create an array of five values
evenly spaced between 0 and 1. array([0, 0.25, 0.5 , 0.75, 1 ])
Documentation
np.random.normal(0,1,(3,3))
Output:
np.random.random
Create a 3x3 array of uniformly
distributed random values between array([[ 0.22032773, -0.53153325, 0.1625384 ],
0 and 1. [ 2.11261584, 0.60143232, -0.2835434 ],
[ 1.38910594, -2.92431186, -1.83753008]])
Documentation
np.reshape arr=np.arange(25)
Creates an array 0 to 25.
Reshaping array to the given arr.reshape(5,5)
dimension. Output:
(5,5)
Documentation
np.random.randint(0,10,(3,3))
Output:
np.random.randint Create a 3x3 array of random
integers in the interval in given array([[2, 5, 1],
range. [9, 1, 9],
[0, 9, 4]])
Documentation
np.eye(3)
Output:
np.eye
Create a n dimension identity array([[1., 0., 0.],
matrix. [0., 1., 0.],
[0., 0., 1.]])
Documentation
np.arange(25)
Output:
np.arrange
array([ 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13,
Create an array between the given
14, 15, 16,
range, starts from 0.
17, 18, 19, 20, 21, 22, 23, 24])
Documentation
my_mat = [[1,2,3],[4,5,6],[7,8,9]]
np.shape
np.shape(my_matt)
Output:
To find a shape of given array.
(3,3)
Documentation