
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 10476 Articles for Python

278 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. Cumulative works like, 5, 5+10, 5+10+15, 5+10+15+20. The 1st parameter is ... Read More

156 Views
To compute the Hyperbolic cosine of the array elements, use the numpy.cosine() method in Python Numpy. The method is equivalent to 1/2 * (np.exp(x) + np.exp(-x)) and np.cos(1j*x). Returns the corresponding hyperbolic cosine 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 ... Read More

145 Views
To get the machine limits information for float types, use 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 npThe min is the minimum value of given dtype and max is the minimum value of given dtype.Checking for float16 type with instances −a = np.finfo(np.float16(12.5)) print("Minimum of float16 type...", a.min) print("Maximum of float16 type...", a.max)Checking for float32 type with instances −b = np.finfo(np.float32(30.5)) print("Minimum of float32 type...", b.min) print("Maximum of float32 type...", b.max)Checking for float type with instances ... Read More

196 Views
To return an array with the number of non-overlapping occurrences of substring, use the numpy.char.count() method in Python Numpy. The first parameter is the sub i.e. the substring to search for. The numpy.char module provides a set of vectorized string operations for arrays of type numpy.str_StepsAt first, import the required library −import numpy as npCreate a One-Dimensional array of strings −arr = np.array(['kATIE', 'JOHN', 'KAte', 'AmY', 'BRADley'])Displaying our array −print("Array...", arr)Get the datatype −print("Array datatype...", arr.dtype) Get the dimensions of the Array −print("Array Dimensions...", arr.ndim)Get the shape of the Array −print("Our Array Shape...", arr.shape)Get the number of elements of the ... Read More

2K+ Views
To round to nearest integer towards zero, use the numpy.fix() method in Python Numpy. It rounds an array of floats element-wise to nearest integer towards zero. The rounded values are returned as floats. The 1st parameter, x is an array of floats to be rounded. The 2nd parameter, out is a location into which the result is stored. If provided, it must have a shape that the input broadcasts to. If not provided or None, a freshly-allocated array is returned.The method returns a float array with the same dimensions as the input. If second argument is not supplied then a ... Read More

2K+ Views
To multiply one polynomial to another, use the numpy.polynomial.polynomial.polymul() method in Python. Returns the multiplication of two polynomials c1 + c2. The arguments are sequences of coefficients from lowest order term to highest, i.e., [1, 2, 3] represents the polynomial 1 + 2*x + 3*x**2.The method returns the coefficient array representing their sum. The parameters c1 and c2 are the 1-D arrays of coefficients representing a polynomial, relative to the “standard” basis, and ordered from lowest order term to highest.This numpy.polynomial.polynomial module provides a number of objects useful for dealing with polynomials, including a Polynomial class that encapsulates the usual ... Read More

433 Views
To subtract one polynomial to another, use the numpy.polynomial.polynomial.polysub() method in Python. Returns the difference of two polynomials c1 + c2. The arguments are sequences of coefficients from lowest order term to highest, i.e., [1, 2, 3] represents the polynomial 1 + 2*x + 3*x**2.The method returns the coefficient array representing their difference. The parameters c1 and c2 returns 1-D arrays of polynomial coefficients ordered from low to high.This numpy.polynomial.polynomial module provides a number of objects useful for dealing with polynomials, including a Polynomial class that encapsulates the usual arithmetic operations.StepsAt first, import the required libraries -from numpy.polynomial import polynomial ... Read More

2K+ Views
To add one polynomial to another, use the numpy.polynomial.polynomial.polyadd() method in Python. Returns the sum of two polynomials c1 + c2. The arguments are sequences of coefficients from lowest order term to highest, i.e., [1, 2, 3] represents the polynomial 1 + 2*x + 3*x**2.The method returns the coefficient array representing their sum.The parameters c1 and c2 returns 1-D arrays of polynomial coefficients ordered from low to high.This numpy.polynomial.polynomial module provides a number of objects useful for dealing with polynomials, including a Polynomial class that encapsulates the usual arithmetic operations.StepsAt first, import the required libraries-from numpy.polynomial import polynomial as PDeclare ... Read More

748 Views
To compute the inverse of a 3D array, use the numpy.linalg.tensorinv() method in Python. The result is an inverse for a relative to the tensordot operation tensordot(a, b, ind), i. e., up to floating-point accuracy, tensordot(tensorinv(a), a, ind) is the “identity” tensor for the tensordot operation. The method returns a’s tensordot inverse, shape a.shape[ind:] + a.shape[:ind].The 1st parameter is a, the Tensor to ‘invert’. Its shape must be ‘square’, i. e., prod(a.shape[:ind]) == prod(a.shape[ind:]). The 2nd parameter is ind, the number of first indices that are involved in the inverse sum. Must be a positive integer, default is 2.StepsAt first, ... Read More

470 Views
To compute the inverse of a Four-Dimensional array, use the numpy.linalg.tensorinv() method in Python. The result is an inverse for a relative to the tensordot operation tensordot(a, b, ind), i. e., up to floating-point accuracy, tensordot(tensorinv(a), a, ind) is the “identity” tensor for the tensordot operation.The method returns a’s tensordot inverse, shape a.shape[ind:] + a.shape[:ind]. The 1st parameter is a, the Tensor to ‘invert’. Its shape must be ‘square’, i. e., prod(a.shape[:ind]) == prod(a.shape[ind:]). The 2nd parameter is ind, the number of first indices that are involved in the inverse sum. Must be a positive integer, default is 2.StepsAt first, ... Read More