Array Operations

 4. Array Operations

array17 = np.array([22, 10, 5, 13, 17, 40, 61, 18])
array18 = np.sort(array17)           
# Smallest to largest number sorting is done
print (array18)

length  = len(array17)                   # Length should equal to reshape parameters multiplied 
array19 = array18.reshape(4,2)   
# Changing the dimension of the array 
print (array19)

array20 = np.array([[11, 22, 33],[44, 55, 66]])

x =  array20.copy()                 
# Copy operation array remian unchanged 
y =  array20.view()                   
# View operation array chnaged the value updated in array 

array20[0,0] = 99

print(array20)
print(x)
print(y)

array21 = array20.reshape(-1)  # converting a multidimensional array into a 1D array.
print(array21)

-------------------------------------------------------------------------------
Table of Content 
--------------------------------------------------------------------------------

No comments: