Found 1204 Articles for Numpy

Return the maximum of an array along axis 0 or maximum ignoring any NaNs in Python

AmitDiwan
Updated on 01-Mar-2022 07:41:11

225 Views

To return the maximum of an array or maximum ignoring any NaNs, use the numpy.nanmax() method in Python. The method returns an array with the same shape as a, with the specified axis removed. If a is a 0-d array, or if axis is None, an ndarray scalar is returned. The same dtype as a is returned. The 1st parameter, a is an array containing numbers whose maximum is desired. If a is not an array, a conversion is attempted.The 2nd parameter, axis is an axis or axes along which the maximum is computed. The default is to compute the ... Read More

Return the maximum of an array along an axis or maximum ignoring any NaNs in Python

AmitDiwan
Updated on 01-Mar-2022 07:39:25

93 Views

To return the maximum of an array or maximum ignoring any NaNs, use the numpy.nanmax() method in Python. The method returns an array with the same shape as a, with the specified axis removed. If a is a 0-d array, or if axis is None, an ndarray scalar is returned. The same dtype as a is returned.The 1st parameter, a is an array containing numbers whose maximum is desired. If a is not an array, a conversion is attempted. The 2nd parameter, axis is an axis or axes along which the maximum is computed. The default is to compute the ... Read More

Return the maximum of an array or maximum ignoring any NaNs in Python

AmitDiwan
Updated on 01-Mar-2022 07:37:51

2K+ Views

To return the maximum of an array or maximum ignoring any NaNs, use the numpy.nanmax() method in Python. The method returns an array with the same shape as a, with the specified axis removed. If a is a 0-d array, or if axis is None, an ndarray scalar is returned. The same dtype as a is returned. The 1st parameter, a is an array containing numbers whose maximum is desired. If a is not an array, a conversion is attempted.The 2nd parameter, axis is an axis or axes along which the maximum is computed. The default is to compute the ... Read More

Return the real part of the complex argument in Python

AmitDiwan
Updated on 01-Mar-2022 07:36:35

200 Views

To return the real part of the complex argument, use the numpy.real() method in Python. The method returns the real component of the complex argument. If val is real, the type of val is used for the output. If val has complex elements, the returned type is float. The 1st parameter, val is the input arrayStepsAt first, import the required libraries −import numpy as npCreate an array using the array() method −arr = np.array([56.+0.j , 27.+0.j , 68.+0.j , 23.+0.j]) Display the array −print("Our Array...", arr)Check the Dimensions −print("Dimensions of our Array...", arr.ndim) Get the Datatype −print("Datatype of our Array ... Read More

Return the angle of the complex argument in radians in Python

AmitDiwan
Updated on 01-Mar-2022 07:34:59

103 Views

To return the angle of the complex argument, use the numpy.angle() method in Python. The method returns the counterclockwise angle from the positive real axis on the complex plane in the range (-pi, pi], with dtype as numpy.float64. The 1st parameter z, A complex number or sequence of complex numbers. The 2nd parameter, deg, return angle in degrees if True, radians if False (default).StepsAt first, import the required libraries −import numpy as npCreate an array using the array() method −arr = np.array([1.0, 1.0j, 1+1j]) Display the array −print("Array...", arr)Get the type of the array −print("Our Array type...", arr.dtype) Get the ... Read More

Compute the square root of input with emath in Python

AmitDiwan
Updated on 01-Mar-2022 07:33:03

122 Views

To compute the square root of input, use the scimath.sqrt() method in Python Numpy. The method returns the square root of x. If x was a scalar, so is out, otherwise an array is returned. The parameter x is the input value. For negative input elements, a complex value is returnedStepsAt first, import the required libraries −import numpy as npCreating a numpy array using the array() method −arr = np.array([1, 4, 9, 16, 25, 36]) Display the array −print("Our Array...", arr)Check the Dimensions −print("Dimensions of our Array...", arr.ndim) Get the Datatype −print("Datatype of our Array object...", arr.dtype)Get the Shape −print("Shape ... Read More

Return real parts if input is complex with all imaginary parts close to zero in Python

AmitDiwan
Updated on 01-Mar-2022 07:31:11

189 Views

To return real parts if input is complex with all imaginary parts close to zero, use the numpy.real_if_close in Python. “Close to zero” is defined as tol * (machine epsilon of the type for a). If a is real, the type of a is used for the output. If a has complex elements, the returned type is float. The 1st parameter is a, the input array. The 2nd parameter is tol, Tolerance in machine epsilons for the complex part of the elements in the array.StepsAt first, import the required libraries −import numpy as npCreating a numpy array using the array() ... Read More

Replace NaN with zero and fill negative infinity for complex input values in Python

AmitDiwan
Updated on 01-Mar-2022 07:29:43

124 Views

To replace NaN with zero and infinity with large finite numbers, use the numpy.nan_to_num() method in Python. The method returns, x, with the non-finite values replaced. If copy is False, this may be x itself. The 1st parameter is the input data. The 2nd parameter is copy, whether to create a copy of x (True) or to replace values in-place. The in-place operation only occurs if casting to an array does not require a copy. Default is True.The 3rd parameter is nan, the value to be used to fill NaN values. If no value is passed then NaN values will ... Read More

Replace NaN with zero and fill positive infinity for complex input values in Python

AmitDiwan
Updated on 01-Mar-2022 07:27:55

158 Views

To replace NaN with zero and infinity with large finite numbers, use the numpy.nan_to_num() method. The method returns, x, with the non-finite values replaced. If copy is False, this may be x itself. The 1st parameter is the input data. The 2nd parameter is copy, whether to create a copy of x (True) or to replace values in-place. The in-place operation only occurs if casting to an array does not require a copy. Default is True.The 3rd parameter is nan, the value to be used to fill NaN values. If no value is passed then NaN values will be replaced ... Read More

Replace infinity with large finite numbers and fill NaN for complex input values in Python

AmitDiwan
Updated on 01-Mar-2022 07:26:10

277 Views

To replace NaN with zero and infinity with large finite numbers, use the numpy.nan_to_num() method in Python. The method returns, x, with the non-finite values replaced. If copy is False, this may be x itself. The 1st parameter is the input data. The 2nd parameter is copy, whether to create a copy of x (True) or to replace values in-place (False). The in-place operation only occurs if casting to an array does not require a copy. Default is True.The 3rd parameter is nan, the value to be used to fill NaN values. If no value is passed then NaN values ... Read More

Advertisements