NumPy || np
import numpy as np
lst1 = [1,2,3,4]
arr = np.array(lst1)
type(arr)
arr
arr.shape
list1=[1,2,3,4]
list2=[6,7,8,9]
list3=[3,4,5,6]
arr = np.array([list1,list2,list3])
arr
arr.shape
arr.reshape(4,3)
arr.reshape(1,12)
arr.shape
arr
arr[0][1]
arr[1:,3:]
arr[1:,2:]
arr[:,2:]
arr[0:2,0:2] # always remember left:right is left exact and right is one value greater than actual one
arr = np.arange(0,10)
arr
arr = np.arange(0,10,step=2)
arr
# shift+tab for elaborate the function
np.linspace(1,10,50)
print(arr)
arr[3:] =100 # replace all indexes starting from 3rd to all by 100
print(arr)
arr1=arr
arr1[3:]=500
arr1
arr # array is actually a reference type hence change is reflected to actual array also
arr1 = arr.copy()
arr1
arr1[3:] = 800
print(arr1)
print(arr)
arr = np.array([1,2,3,4,5])
val = 2
arr
print(arr<2)
print(arr*2)
print(arr%2)
arr[arr<2]
np.ones((2,5),dtype=int)
np.ones(4)
np.random.rand(3,3)
arr_ex = np.random.randn(4,4) # selects from random distribution
arr_ex
arr_ex.reshape(16,1)
import seaborn as sns
import pandas as pd
sns.distplot(pd.DataFrame(arr_ex.reshape(16,1)))
np.random.randint(0,100,8).reshape(4,2)
np.random.random_sample((1,5))