Found 10476 Articles for Python

Return a boolean array which is True where the string element in array ends with suffix in Python

AmitDiwan
Updated on 01-Mar-2022 08:10:25

162 Views

To return a boolean array which is True where the string element in array ends with suffix, use the numpy.char.endswith() method in Python Numpy. The first parameter is the input array. The second parameter is the suffix. The numpy.char module provides a set of vectorized string operations for arrays of type numpy.str_StepsAt first, import the required libraries −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 ... Read More

Get the Inner product of two arrays in Python

AmitDiwan
Updated on 01-Mar-2022 08:09:07

3K+ Views

To get the Inner product of two arrays, use the numpy.inner() method in Python. Ordinary inner product of vectors for 1-D arrays, in higher dimensions a sum product over the last axes. The parameters are 1 and b, two vectors. If a and b are nonscalar, their last dimensions must match.StepsAt first, import the required libraries −import numpy as npCreating two numpy One-Dimensional array using the array() method −arr1 = np.array([5, 10, 15]) arr2 = np.array([20, 25, 30])Display the arrays −print("Array1...", arr1) print("Array2...", arr2)Check the Dimensions of both the arrays −print("Dimensions of Array1...", arr1.ndim) print("Dimensions of Array2...", arr2.ndim)Check the Shape ... Read More

Return the dot product of One-Dimensional vectors in Python

AmitDiwan
Updated on 01-Mar-2022 08:07:16

354 Views

To return the dot product of One-Dimensional vectors, use the numpy.vdot() method in Python. The vdot(a, b) function handles complex numbers differently than dot(a, b). If the first argument is complex the complex conjugate of the first argument is used for the calculation of the dot product. The vdot handles multidimensional arrays differently than dot: it does not perform a matrix product, but flattens input arguments to 1-D vectors first. Consequently, it should only be used for vectors.The method returns the dot product of a and b. Can be an int, float, or complex depending on the types of a ... Read More

Return the dot product of two multidimensional vectors in Python

AmitDiwan
Updated on 01-Mar-2022 08:05:57

538 Views

To return the dot product of two multi-dimensional vectors, use the numpy.vdot() method in Python. The vdot(a, b) function handles complex numbers differently than dot(a, b). If the first argument is complex the complex conjugate of the first argument is used for the calculation of the dot product. The vdot handles multidimensional arrays differently than dot: it does not perform a matrix product, but flattens input arguments to 1-D vectors first. Consequently, it should only be used for vectors.The method returns the dot product of a and b. Can be an int, float, or complex depending on the types of ... Read More

Return the dot product of two vectors in Python

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

3K+ Views

To return the dot product of two vectors, use the numpy.vdot() method in Python. The vdot(a, b) function handles complex numbers differently than dot(a, b). If the first argument is complex the complex conjugate of the first argument is used for the calculation of the dot product. The vdot handles multidimensional arrays differently than dot: it does not perform a matrix product, but flattens input arguments to 1-D vectors first. Consequently, it should only be used for vectors.The method returns the dot product of a and b. Can be an int, float, or complex depending on the types of a ... Read More

Compute the inverse hyperbolic tangent with scimath in Python

AmitDiwan
Updated on 01-Mar-2022 08:02:05

205 Views

To compute the inverse hyperbolic tangent with arctanh, use the numpy.emath.arctanh() method in Python. Returns the “principal value” of arctanh(x). For real x such that abs(x) < 1, this is a real number. If abs(x) > 1, or if x is complex, the result is complex. Finally, x = 1 returns``inf`` and x=-1 returns -inf.The method returns the inverse hyperbolic tangent(s) of the x value(s). If x was a scalar so is out, otherwise an array is returned. The 1st parameter is the value(s) whose arctanh is (are) required.StepsAt first, import the required libraries −import numpy as npCreate a numpy ... Read More

Compute the inverse sine with scimath in Python

AmitDiwan
Updated on 01-Mar-2022 08:00:27

235 Views

To compute the inverse sine with scimath, use the numpy.emath.arcsin() method in Python. Returns the “principal value” of the inverse sine of x. For real x such that abs(x)

Compute the inverse cosine with scimath in Python

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

155 Views

To compute the inverse cosine with scimath, use the numpy.emath.arccos() method in Python. Return the “principal value” of the inverse cosine of x. For real x such that abs(x)

Return the result of the power to which the negative input value is raised with scimath in Python

AmitDiwan
Updated on 01-Mar-2022 07:57:14

135 Views

To return the result of the power to which the input value is raised with scimath, use the scimath.power() method in Python. Returns x to the power p, i.e. the result of x**p. If x and p are scalars, so is out, otherwise an array is returned.If x contains negative values, the output is converted to the complex domain. The parameter x is the input value. The parameter p is the power(s) to which x is raised. If x contains multiple values, p has to either be a scalar, or contain the same number of values as x. In the ... Read More

Return the result of the power to which the input value is raised with scimath in Python

AmitDiwan
Updated on 01-Mar-2022 07:53:21

154 Views

To return the result of the power to which the input value is raised with scimath, use the scimath.power() method in Python. Returns x to the power p, i.e. the result of x**p. If x and p are scalars, so is out, otherwise an array is returned. If x contains negative values, the output is converted to the complex domain. The parameter x is the input valueThe parameter p is the power(s) to which x is raised. If x contains multiple values, p has to either be a scalar, or contain the same number of values as x. In the ... Read More

Advertisements