Numeric Python, it is a Linear Algebra Library for Python. It is the basic building block for almost all python compatible data science libraries. Numpy is also incredibly fast. Here, Numpy arrays are used instead of normal python lists.
Numpy arrays essentially come in two flavors: vectors and matrices. Vectors are strictly 1-d arrays and matrices are 2-d.
- np.array(list1) - convert lits to array
- np.arange(1,100,5) - #1st argument- start value, 2nd argument - end value(exclusive), 3rd argument - step size
- np.zeros((4,3)) - #argument is a tuple, in tuple we need to specify number of rows and columns.it gives 4 x 3 matix with zeros.
- np.linspace(0,10,3)- #3rd argument for total numbers to be generated.Returns evenly spaced numbers over a specified interval
- np.eye(5)- Creates an identity matrix with 5 x 5.
- np.random.rand(4,4)- #rand: Generates uniformly distributed random numbers over (0, 1)
- np.random.randn(4,4)- #randn: Generates normally distributed(standard normal distribution) random numbers.
- np.random.randint(12,100,9) - #randint: Generates random integers over given range. #3rd argument for total numbers to be generated.
- max(), min() for finding minimum and maximum value.
- argmax(),argmin() for index of min and max elements.
- array1.shape - #Shape is an attribute that denotes dimension(shape) of array.
- array1.reshape(1,20)- # Notice the two sets of brackets
- slice, Indexing and Selection
- np.sqrt(arr)- #for Square Roots
- np.exp(arr)- #for exponential (e^)
- np.multiply(a1,b1) or a1xb1- #Multipication
- a1.dot(b1) - #Matrix multiplication