1.numpy list

import numpy as np

mylist = [1,2,3]
arr = np.array(mylist)
np.arange(0,11,2) #stepsize
np.arange(10)# 0-9 list
np.zeros(3)
np.zeros((3,4)) #3d
np.ones(1)
np.ones((3,4)) #3d
np.linspace(1,10,10) #equally space of total length n
np.eye(4)#identity matrix
np.random.rand() #return single digit
np.random.rand(5) #random of (0,1) of length n return array
np.random.rand((5,5))#3d
np.random.randn(5)#return 1d array but with the distribution around 0
np.random.randn((5,5))
np.random.randint(1,100,10)#inc #exc #number of output
np.reshape(5,5) #you need 50 elements to reshape the array to this dimension
arr.max()#return max
arr.min()#return min
arr.sum()#return sum
arr.std()#return standard deviation
arr.argmax()#return argument of max
arr.argmin()#return argument of min
arr.shape#return shape of the array
arr.dtype#return dtype of the array

2.Numpy Indexing and Selection

import numpy as np
arr = np.arange(0,11)
#normal slicing like lists
arr2 = arr.copy()
arr[2][1] #-> for 2d array can also be written as arr[2,1]
arr[:2,:1] # it's like take everything upto 2nd row and take everything upto 1: column workwith comma only
# if i do something like arr > 5 , i will get the boolean value arr
# bool_arr = arr > 5
arr = arr[arr>5] #i will get the main arr, where the boolarray is true

3.numpy operation

import numpy as np

arr = np.arange(0,11)
#this will go with each individual elements
arr+arr
arr-arr
arr/arr
arr+100

np.sqrt(arr)
np.exp(arr)
np.max(arr)
np.log(arr)

err, or mistake

np.ones(10) * 5 ->np.linspace(5,5,10)
np.arange(1,101).reshape(10,10) / 100 ->np.linspace(0.01,1,100).reshape(10,10)

IMG_3441.jpeg