 
 Data Structure Data Structure
 Networking Networking
 RDBMS RDBMS
 Operating System Operating System
 Java Java
 MS Excel MS Excel
 iOS iOS
 HTML HTML
 CSS CSS
 Android Android
 Python Python
 C Programming C Programming
 C++ C++
 C# C#
 MongoDB MongoDB
 MySQL MySQL
 Javascript Javascript
 PHP 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
Numpy Articles - Page 54 of 121
 
 
			
			146 Views
To generate a Vandermonde matrix of the Chebyshev polynomial, use the chebyshev.chebvander() in Python Numpy. The method returns the Vandermonde matrix. The shape of the returned matrix is x.shape + (deg + 1, ), where The last index is the degree of the corresponding Chebyshev polynomial. The dtype will be the same as the converted x.The parameter, a is Array of points. The dtype is converted to float64 or complex128 depending on whether any of the elements are complex. If x is scalar it is converted to a 1-D array. The parameter, deg is the degree of the resulting matrix.StepsAt ... Read More
 
 
			
			195 Views
The arctanh is a multivalued function: for each x there are infinitely many numbers z such that tanh(z) = x. The convention is to return the z whose imaginary part lies in [-pi/2, pi/2]. The inverse hyperbolic tangent is also known as atanh or tanh^-1.To compute the inverse Hyperbolic tangent of array elements, use the numpy.arctanh() method in Python Numpy. The method returns the array of the same shape as x. 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 ... Read More
 
 
			
			167 Views
To calculate the n-th discrete difference, use the numpy.diff() method. The first difference is given by out[i] = a[i+1] - a[i] along the given axis, higher differences are calculated by using diff recursively. The diff() method returns the n-th differences. The shape of the output is the same as a except along axis where the dimension is smaller by n. The type of the output is the same as the type of the difference between any two elements of a. This is the same as the type of a in most cases. A notable exception is datetime64, which results in ... Read More
 
 
			
			166 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 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 which the elements are summed. If dtype ... Read More
 
 
			
			159 Views
The numpy.can_cast() method returns True if scalar and data type can occur according to the casting rule. The 1st parameter is the scalar or data type or array to cast from. The 2nd parameter is the data type to cast to.StepsAt first, import the required library −import numpy as npChecking if scalar and data type can occur according to the casting rule. −print("Checking with can_cast() method in Numpy") print("Result...", np.can_cast(20, 'i1')) print("Result...", np.can_cast(280, 'i1')) print("Result...", np.can_cast(80, 'u1')) print("Result...", np.can_cast(300.7, np.float32)) print("Result...", np.can_cast(120.6, np.float64)) print("Result...", np.can_cast(7.2e100, np.float32)) print("Result...", np.can_cast(6.5e100, np.float64))Exampleimport numpy as np # The numpy.can_cast() method returns True if ... Read More
 
 
			
			121 Views
The numpy.can_cast() method returns True if cast between data types can occur according to the casting rule. The 1st parameter is the data type or array to cast from. The 2nd parameter is the data type to cast to.StepsAt first, import the required library −import numpy as npUsing the can_cast() to check if cast between data types can occur according to the casting rule −print("Checking with can_cast() method in Numpy") print("Result...", np.can_cast(np.int32, np.int64)) print("Result...", np.can_cast(np.float64, complex)) print("Result...", np.can_cast(complex, float)) print("Result...", np.can_cast('i8', 'f8')) print("Result...", np.can_cast('i8', 'f4')) print("Result...", np.can_cast('i4', 'S4'))Exampleimport numpy as np # The numpy.can_cast() method returns True if cast ... Read More
 
 
			
			3K+ Views
To convert an array of datetimes into an array of strings, use the numpy.datetime_as_string() method in Python Numpy, The method returns an array of strings the same shape as the input array. The first parameter is the array of UTC timestamps to format. The "units" parameter sets the datetime unit to change the precision.StepsAt first, import the required library −import numpy as npCreate an array of datetime. The 'M' type specifies datetime −arr = np.arange('2022-02-20T02:10', 6*60, 60, dtype='M8[m]')To convert an array of datetimes into an array of strings, use the numpy.datetime_as_string() method in Python Numpy −print("Result...", np.datetime_as_string(arr, unit ='m'))Exampleimport numpy ... Read More
 
 
			
			480 Views
To get the hypotenuse, use the numpy.hypot() method in Python Numpy. The method returns the hypotenuse of the triangle(s). This is a scalar if both x1 and x2 are scalars. This method is equivalent to sqrt(x1**2 + x2**2), element-wise. If x1 or x2 is scalar_like, it is broadcast for use with each element of the other argument. The parameters are the leg of the triangle(s). If x1.shape != x2.shape, they must be broadcastable to a common shape.StepsAt first, import the required library −import numpy as npCreating an array with integer elements −arr = np.ones((3, 3), dtype=int)Displaying our array −print("Array...", arr)Get ... Read More
 
 
			
			1K+ Views
The arctan is a multi-valued function: for each x there are infinitely many numbers z such that tan(z) = x. # The inverse tangent is also known as atan or tan^{-1}.The convention is to return the angle z whose real part lies in [-pi/2, pi/2]. For real-valued input data types, arctan always returns real output. For each value that cannot be expressed as a real number or infinity, it yields nan and sets the invalid floating point error flag. For complex-valued input, arctan is a complex analytic function that has [1j, infj] and [-1j, -infj] as branch cuts, and is ... Read More
 
 
			
			4K+ Views
The arctan is a multi-valued function: for each x there are infinitely many numbers z such that tan(z) = x. The convention is to return the angle z whose real part lies in [-pi/2, pi/2]. The inverse tangent is also known as atan or tan^{-1}.For real-valued input data types, arctan always returns real output. For each value that cannot be expressed as a real number or infinity, it yields nan and sets the invalid floating point error flag. For complex-valued input, arctan is a complex analytic function that has [1j, infj] and [-1j, -infj] as branch cuts, and is continuous ... Read More