
Data Structure
Networking
RDBMS
Operating System
Java
MS Excel
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
Found 33676 Articles for Programming

147 Views
To return the cumulative sum of array elements over a given axis treating NaNs as zero, use the nancumprod() method. The cumulative sum does not change when NaNs are encountered and leading NaNs are replaced by zeros. Zeros are returned for slices that are all-NaN or empty. The method returns a new array holding the result unless out is specified, in which it is returned. The result has the same size as a, and the same shape as a if axis is not None or a is a 1-d array.The 1st parameter is the input array. The 2nd parameter is ... Read More

230 Views
To return the cumulative sum of array elements over a given axis treating NaNs as zero, use the nancumprod() method. The cumulative sum does not change when NaNs are encountered and leading NaNs are replaced by zeros. Zeros are returned for slices that are all-NaN or empty. Cumulative works like, 5, 5+10, 5+10+15, 5+10+15+20.The 1st parameter is the input array. The 2nd parameter is the axis along which the cumulative sum is computed. The default (None) is to compute the cumsum over the flattened array. The 3rd parameter is the type of the returned array and of the accumulator in ... Read More
Return the type that results from applying the NumPy type promotion rules to the arguments in Python

151 Views
The numpy.result_type() method returns the type that results from applying the NumPy type promotion rules to the arguments. The 1st parameter is the operands of some operation whose result type is needed. Type promotion in NumPy works similarly to the rules in languages like C++, with some slight differences. When both scalars and arrays are used, the array’s type takes precedence and the actual value of the scalar is taken into account.StepsAt first, import the required library −import numpy as npThe numpy.result_type() method returns the type that results from applying the NumPy type promotion rules to the arguments −print("Using the ... Read More

193 Views
The numpy.min_scalar() method finds the minimal data type. The 1st parameter is the value whose minimal data type is to be found. For scalar, returns the data type with the smallest size and smallest scalar kind which can hold its value. For non-scalar array, returns the vector’s dtype unmodified. Floating point values are not demoted to integers, and complex values are not demoted to floats.StepsAt first, import the required library −import numpy as npThe numpy.min_scalar() method finds the minimal data type. The 1st parameter is the value whose minimal data type is to be found −print("Using the min_scalar() method in ... Read More

665 Views
To get the approximate number of decimal digits to which this kind of float is precise, use the precision attribute of the numpy.finfo() method in Python Numpy. The first parameter of the finfo() is the float i.e. the kind of float data type to get information about.StepsAt first, import the required library −import numpy as npChecking for float16 type. The precision is to get the approximate number of decimal digits. The iexp is to get the number of bits in the exponent portion. The min is the minimum value of given dtype. The max is the minimum value of given ... Read More

610 Views
To get the number of bits in the exponent portion of the floating point representation, use the iexp attribute of the numpy.finfo() method in Python Numpy. The first parameter is the float i.e. the kind of float data type to get information about.StepsAt first, import the required library −import numpy as npChecking for float16 type. The iexp is to get the number of bits in the exponent portion. The min is the minimum value of given dtype. The max is the minimum value of given dtype. −a = np.finfo(np.float16(45.9)) print("Number of bits in the exponent portion float16 type...", a.iexp) print("Minimum ... Read More

204 Views
To compute the Hyperbolic tangent of the array elements, use the numpy.tanh() method in Python Numpy. The method is equivalent to np.sinh(x)/np.cosh(x) or -1j * np.tan(1j*x). Returns the corresponding hyperbolic tangent values. This is a scalar if x is a scalar. The 1st parameter, x is input array. The 2nd and 3rd parameters are optional.The 2nd parameter is an ndarray, 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.The 3rd parameter is the condition is broadcast over the input. ... Read More

492 Views
To compute the Hyperbolic tangent, use the numpy.tanh() method in Python Numpy. Equivalent to np.sinh(x)/np.cosh(x) or -1j * np.tan(1j*x). Returns the corresponding hyperbolic tangent values. This is a scalar if x is a scalar. The 1st parameter, x is input array. The 2nd and 3rd parameters are optional.The 2nd parameter is an ndarray, 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.The 3rd parameter is the condition is broadcast over the input. At locations where the condition is True, ... Read More

674 Views
To get the machine limits information for float types, use the numpy.finfo() method in Python Numpy. The first parameter is the floating type i.e. the kind of float data type to get information about.StepsAt first, import the required library −import numpy as npThe min is the minimum value of given dtype and max is the minimum value of given dtype.Checking for float16 type −a = np.finfo(np.float16) print("Minimum of float16 type...", a.min) print("Maximum of float16 type...", a.max)Checking for float32 type −b = np.finfo(np.float32) print("Minimum of float32 type...", b.min) print("Maximum of float32 type...", b.max)Checking for float64 type −c = np.finfo(np.float64) print("Minimum of ... Read More

187 Views
To get the machine limits information for integer types, use the numpy.iinfo() method in Python Numpy. The first parameter is the int_type i.e. the kind of integer data type to get information about.StepsAt first, import the required library −import numpy as npThe min is the minimum value of given dtype and max is the minimum value of given dtype.Checking for int16 type with instances −a = np.iinfo(np.int16(20)) print("Minimum of int16 type...", a.min) print("Maximum of int16 type...", a.max)Checking for int32 type with instances −b = np.iinfo(np.int32(30)) print("Minimum of int32 type...", b.min) print("Maximum of int32 type...", b.max)Checking for int64 type with instances ... Read More