• How To Remove Elements From Numpy Array?

    How To Remove Elements From Numpy Array?

    How To Remove Elements From Numpy Array? Table Of Contents: np.delete( ) Examples Of np.delete() Method. (1) np.delete( ) A copy of arr with the elements specified by obj removed. Note that delete does not occur in-place. If axis is None, out is a flattened array. Syntax: numpy.delete(arr, obj, axis=None) Parameters: arr: array_like – Input array. obj: slice, int or array of ints – Indicate indices of sub-arrays to remove along the specified axis. axis: int, optional – The axis along which to delete the subarray defined by obj. If axis is None, obj is applied to the flattened array. Returns: out: ndarray – A copy of arr with the elements specified by obj removed. Note that delete does not occur

    Read More

  • How To Sort A Numpy Array ?

    How To Sort A Numpy Array ?

    How To Sort A Numpy Array? Table Of Contents: np.sort( ) Examples Of Sorting Numpy Array. (1) np.sort( ) Return a sorted copy of an array. Syntax: numpy.sort(a, axis=-1, kind=None, order=None) Parameters: a: array_like – Array to be sorted. axis: int or None, optional – Axis along which to sort. If None, the array is flattened before sorting. The default is -1, which sorts along the last axis. kind: {‘quicksort’, ‘mergesort’, ‘heapsort’, ‘stable’}, optional – Sorting algorithm. The default is ‘quicksort’.  order: str or list of str, optional – When a is an array with fields defined, this argument specifies which fields to

    Read More

  • How To Add Numpy Arrays ?

    How To Add Numpy Arrays ?

    How To Add Numpy Arrays ? Table Of Contents: ‘+’  Operator np.concatenate() (1) ‘+’ Operator The  ‘+’ operator will ‘sum’ the elements of numpy array. Example-1 a = np.array([1,2,3,4,5]) b = np.array([6,7,8,9,10]) a + b Output: array([ 7, 9, 11, 13, 15]) Example-2 a = np.array([1,2,3,4,5]) b = np.array([6,7,8,9,10]) c = np.array([11,12,13,14,15]) a + b + c Output: array([18, 21, 24, 27, 30]) (2) np.concatenate() Join a sequence of arrays along an existing axis. Syntax: numpy.concatenate((a1, a2, …), axis=0, out=None, dtype=None, casting="same_kind") Parameters: a1, a2, …sequence of array_like –  The arrays must have the same shape, except in the dimension

    Read More