numpy.negative() in Python Last Updated : 28 Nov, 2018 Comments Improve Suggest changes Like Article Like Report numpy.negative() function is used when we want to compute the negative of array elements. It returns element-wise negative value of an array or negative value of a scalar. Syntax : numpy.negative(arr, /, out=None, *, where=True, casting='same_kind', order='K', dtype=None, subok=True[, signature, extobj], ufunc 'negative') Parameters : arr : [array_like or scalar] Input array. dtype : The type of the returned array. By default, the dtype of arr is used. out : [ndarray, optional] A location into which the result is stored. -> If provided, it must have a shape that the inputs broadcast to. -> If not provided or None, a freshly-allocated array is returned. where : [array_like, optional] Values of True indicate to calculate the ufunc at that position, values of False indicate to leave the value in the output alone. **kwargs : Allows to pass keyword variable length of argument to a function. Used when we want to handle named argument in a function. Return : [ndarray or scalar] Returned array or scalar = -(input arr or scalar ) Code #1 : Working Python # Python program explaining # numpy.negative() function import numpy as geek in_num = 10 print ("Input number : ", in_num) out_num = geek.negative(in_num) print ("negative of input number : ", out_num) Output : Input number : 10 negative of input number : -10 Code #2 : Python # Python program explaining # numpy.negative function import numpy as geek in_arr = geek.array([[2, -7, 5], [-6, 2, 0]]) print ("Input array : ", in_arr) out_arr = geek.negative(in_arr) print ("negative of array elements: ", out_arr) Output : Input array : [[ 2. 2. 2.] [ 2. 2. nan]] product of array elements: 32.0Input array : [[ 2 -7 5] [-6 2 0]] negative of array elements: [[-2 7 -5] [ 6 -2 0]] Comment More infoAdvertise with us Next Article numpy.negative() in Python jana_sayantan Follow Improve Article Tags : Python Python-numpy Python numpy-Mathematical Function Practice Tags : python Similar Reads numpy.isneginf() in Python The numpy.isneginf() function tests element-wise whether it is negative infinity or not, and returns the result as a boolean array. Syntax :  numpy.isneginf(array, y = None) Parameters : array : [array_like]Input array or object whose elements, we need to test for infinity. y : [array_like]A boole 2 min read numpy.invert() in Python numpy.invert() function is used to Compute the bit-wise Inversion of an array element-wise. It computes the bit-wise NOT of the underlying binary representation of the integers in the input arrays. For signed integer inputs, the twoâs complement is returned. In a twoâs-complement system negative num 2 min read numpy.isnan() in Python The numpy.isnan() function tests element-wise whether it is NaN or not and returns the result as a boolean array. Syntax : numpy.isnan(array [, out]) Parameters : array : [array_like]Input array or object whose elements, we need to test for infinity out : [ndarray, optional]Output array placed wit 2 min read numpy.nonzero() in Python numpy.nonzero()function is used to Compute the indices of the elements that are non-zero. It returns a tuple of arrays, one for each dimension of arr, containing the indices of the non-zero elements in that dimension. The corresponding non-zero values in the array can be obtained with arr[nonzero(ar 2 min read numpy.isinf() in Python The numpy.isinf() function tests element-wise whether it is +ve or -ve infinity or not return the result as a boolean array. Syntax: numpy.isinf(array [, out]) Parameters :  array : [array_like]Input array or object whose elements, we need to test for infinity out : [ndarray, optional]Output array 2 min read Python | Numpy np.negative_binomial() method With the help of np.negative_binomial() method, we can get the array of negative binomial series by using np.negative_binomial() method. Syntax : np.negative_binomial(n, p, size) Return : Return an array of negative binomial series. Example #1 : In this example we can see that by using np.negative_b 1 min read numpy.any() in Python The numpy.any() function tests whether any array elements along the mentioned axis evaluate to True. Syntax : numpy.any(a, axis = None, out = None, keepdims = class numpy._globals._NoValue at 0x40ba726c) Parameters : array :[array_like]Input array or object whose elements, we need to test. axis : 3 min read numpy.nan_to_num() in Python numpy.nan_to_num() function is used when we want to replace nan(Not A Number) with zero and inf with finite numbers in an array. It returns (positive) infinity with a very large number and negative infinity with a very small (or negative) number. Syntax : numpy.nan_to_num(arr, copy=True) Parameters 2 min read numpy.isposinf() in Python The numpy.isposinf() function tests element-wise whether it is positive infinity or not and returns the result as a boolean array. Syntax : numpy.isposinf(array, y = None) Parameters:  array : [array_like]Input array or object whose elements, we need to test for infinity. y : [array_like]A boolea 2 min read Slicing with Negative Numbers in Python Slicing is an essential concept in Python, it allows programmers to access parts of sequences such as strings, lists, and tuples. In this article, we will learn how to perform slicing with negative indexing in Python.Indexing in PythonIn the world of programming, indexing starts at 0, and Python als 5 min read Like