• More Useful Array Operations.

    More Useful Array Operations.

    More Useful Array Operations. Table Of Contents: Maximum, Minimum, Sum, Mean, Product, Standard Deviation (1) data.max() data.max( ) will give you the ‘max’ value present in the array. Example: import numpy as np data = np.array([3,1,5,9,2,-3,9,10]) data.max() Output: 10 (2) data.min() data.min( ) will give you the ‘minimum’ value present in the array. Example: import numpy as np data = np.array([3,1,5,9,2,-3,9,10]) data.min() Output: -3 (3) data.sum() data.sum( ) will give you the ‘sum’ of values present in the array. Example: import numpy as np data = np.array([3,1,5,9,2,-3,9,10]) data.sum() Output: 36 (4) np.prod() np.prod( ) will give you the ‘product’ of values

    Read More

  • What Is Numpy Broadcasting ?

    What Is Numpy Broadcasting ?

    What Is Numpy Broadcasting ? Table Of Contents: What Is Broadcasting ? Examples Of Broadcasting. (1) What Is Broadcasting ? The term broadcasting describes how NumPy treats arrays with different shapes during arithmetic operations.  Subject to certain constraints, the smaller array is “broadcast” across the larger array so that they have compatible shapes. (2) Examples Of Broadcasting ? Example-1: import numpy as np data = np.array([1.0, 2.0]) data * 1.6 Output: array([1.6, 3.2]) Example-2: a = np.array([[ 0.0, 0.0, 0.0], [10.0, 10.0, 10.0], [20.0, 20.0, 20.0], [30.0, 30.0, 30.0]]) b = np.array([1.0, 2.0, 3.0]) a + b Output: array([[ 1.,

    Read More

  • Basic Numpy Array Operations.

    Basic Numpy Array Operations.

    Basic Numpy Array Operations. Table Of Contents: addition, subtraction, multiplication, division sum( ) (1) Numpy Addition You can use ‘+’ operator for addition operation. Example: data = np.array([1, 2]) data array([1, 2]) ones = np.ones(2, dtype=int) ones array([1, 1]) data + ones Output: array([2, 3]) (2) Numpy Substraction You can use ‘-‘ operator for subtraction operation. Example: data = np.array([1, 2]) data array([1, 2]) ones = np.ones(2, dtype=int) ones array([1, 1]) data – ones Output: array([0, 1]) (3) Numpy Multiplication You can use ‘*’ operator for multiplication operation. Example: data = np.array([1, 2]) data array([1, 2]) ones = np.ones(2, dtype=int) ones

    Read More

  • How To Create An Array From Existing Data ?

    How To Create An Array From Existing Data ?

    How To Create An Array From Existing Data ? Table Of Contents: Slicing and Indexing np.vstack( ) np.hstack( ) np.hsplit( ) .view( ) copy( ) (1) Slicing and Indexing You can easily create a new array from a section of an existing array. You need to mention the start and end index position of the array. Example: import numpy as np a = np.array([1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) arr1 = a[3:8] arr1 Output: array([4, 5, 6, 7, 8]) Note: Here I have created a new array from an existing array by mentioning the start and

    Read More