view(): ======= ==> a built-in function which can be used to create an array from another array by changing the datatype in the new array. ex: a = [1,2,3,4,5] a_view_float = [1.0,2.0,3.0,4.0,5.0] Syntax: source_array_name.view(dtype) import numpy a = numpy.array([1,2,3,4,5,6,7,8,9,10],dtype = numpy.int64) print("The Given Array is = ",a) print("The Type of the given Array is = ",a.dtype) # creating the array from above array with same elements b = a.view(dtype = 'f4') print("The Copied Array is = ",b) print("The Type of The Above Array = ",b.dtype) ============================================ reshape(): ========== a = 3 X 4 = 12 b = 4 X 3 = 12 ==> built-in function which can be used to create the array from another array by reshaping the original array. Syntax: source_array.reshape((x,y)) import numpy a = numpy.array([1,3,5,7,9,10,8,6,4,2],dtype = 'i2') c = numpy.array([1,2,3,4,5,6,7,8,9]) e = numpy.array([[1,2,3,4],[5,6,7,8],[9,10,11,12]]) print("The Original Array = ",a) print("The Type = ",a.dtype) # creating the new array from a by reshape b = a.reshape((5,2)) d = c.reshape((3,3)) f = e.reshape((2,3,2)) print("The Reshaped Array = ",b) print("The Type = ",b.dtype) print("The Reshaped Array = ",d) print("The Type = ",d.dtype) print(f) ========================================== Slicing: ======== ==> slicing can be used to access the part of the collection. ==> Array Indexing is possible with both +eve and -eve indexing import numpy a = numpy.array([1,2,3,4,5,6,7,8,9,10]) print(a[0],a[1],a[2],a[3],a[4],a[5],a[6],a[7],a[8],a[9]) # Positive Indeixng print(a[-1],a[-2],a[-3],a[-4],a[-5],a[-6],a[-7],a[-8],a[-9],a[-10]) Slicing: ======== import numpy a = numpy.array([1,3,5,7,9,2,4,6,8,10]) print(a[::1]) print(a[::-1]) print(a[3:8]) print(a[-10:-4]) ====================================== # WAP TO CREATE THE ARRAY WITH RANGE OF OBJECTS. import numpy # Generating the range of objects range_objects = range(1,11) a = numpy.array(range_objects) b = numpy.array(range(10,101,10)) print("The Array = ",a) print("The Type = ",a.dtype) print("The Array = ",b) print("The Type = ",b.dtype) =========================================== logspace(): =========== ==> built-in function ==> can use to generate the array with the values that are evenly spaced on a log scale. Syntax: numpy.logspace(start, stop, num, endpoint = True, base = 10.0, dtype) range(1,10) ==> 1 to 9 range(1,11) ==> 1 to 10 import numpy a = numpy.logspace(1,10,10,base = 2,dtype = 'f2') print("a = ",a) print("Type = ",a.dtype) ========================================== Array-Iteration: ================= 1) using for loop: ================== import numpy a = numpy.array([1,3,5,7,9]) # iteration on array using for loop (forward looping) for i in a: print(i) print() # reverse looping for i in a[::-1]: print(i) ==================================== import numpy a = numpy.array([[1,2,3],[4,5,6],[7,8,9]]) print(a[0]) print(a[1]) print(a[2]) print(a[0][0]) print(a[0][1]) print(a[0][2]) for i in a: print(i) for i in a: for j in i: print(j)