- Trending Categories
Data Structure
Networking
RDBMS
Operating System
Java
MS Excel
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
Physics
Chemistry
Biology
Mathematics
English
Economics
Psychology
Social Studies
Fashion Studies
Legal Studies
- 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 1204 Articles for Numpy
![AmitDiwan](https://www.tutorialspoint.com/assets/profiles/123055/profile/60_187394-1565938756.jpg)
228 Views
To return the string representation of a scalar dtype, use the sctype2char() method in Python Numpy. The 1st argument, if a scalar dtype, the corresponding string character is returned. If an object, sctype2char tries to infer its scalar type and then return the corresponding string character.StepsAt first, import the required library −import numpy as npThe string representation of a scalar type −for i in [np.int32, np.double, np.complex_, np.string_, np.ndarray]: print(np.sctype2char(i))Return the string representation of int types −print("The string representation of int types...") for j in [np.int16, np.int32, np.int64]: print(np.sctype2char(j))Return the string representation of float types −print("The string representation ... Read More
![AmitDiwan](https://www.tutorialspoint.com/assets/profiles/123055/profile/60_187394-1565938756.jpg)
140 Views
To return a description for the given data type code, use the typename() method in Python Numpy. NumPy offers comprehensive mathematical functions, random number generators, linear algebra routines, Fourier transforms, and more. It supports a wide range of hardware and computing platforms, and plays well with distributed, GPU, and sparse array libraries.StepsAt first, import the required library −import numpy as npOur array −arr = ['S1', '?', 'B', 'D', 'G', 'F', 'I', 'H', 'L', 'O', 'Q', 'S', 'U', 'V', 'b', 'd', 'g', 'f', 'i', 'h', 'l', 'q']To return a description for the given data type code, use the typename() method in ... Read More
![AmitDiwan](https://www.tutorialspoint.com/assets/profiles/123055/profile/60_187394-1565938756.jpg)
181 Views
To integrate along the given axis using the composite trapezoidal rule, use the numpy.trapz() method. If x is provided, the integration happens in sequence along its elements - they are not sorted. The method returns the definite integral of ‘y’ = n-dimensional array as approximated along a single axis by the trapezoidal rule. If ‘y’ is a 1-dimensional array, then the result is a float. If ‘n’ is greater than 1, then the result is an ‘n-1’ dimensional array.The 1st parameter, y is the input array to integrate. The 2nd parameter, x is the sample points corresponding to the y ... Read More
![AmitDiwan](https://www.tutorialspoint.com/assets/profiles/123055/profile/60_187394-1565938756.jpg)
219 Views
To integrate along the given axis using the composite trapezoidal rule, use the numpy.trapz() method. If x is provided, the integration happens in sequence along its elements - they are not sorted. The method returns the definite integral of ‘y’ = n-dimensional array as approximated along a single axis by the trapezoidal rule. If ‘y’ is a 1-dimensional array, then the result is a float. If ‘n’ is greater than 1, then the result is an ‘n-1’ dimensional array.The 1st parameter, y is the input array to integrate. The 2nd parameter, x is the sample points corresponding to the y ... Read More
![AmitDiwan](https://www.tutorialspoint.com/assets/profiles/123055/profile/60_187394-1565938756.jpg)
4K+ Views
To compute the cross product of two vectors, use the numpy.cross() method in Python Numpy. The method returns c, the Vector cross product(s). The 1st parameter is a, the components of the first vector(s). The 2nd parameter is b, the components of the second vector(s). The 3rd parameter is axisa, the axis of a that defines the vector(s). By default, the last axis. The 4th parameter is axisb, the axis of b that defines the vector(s). By default, the last axis. The 5th parameter is axisc, the axis of c containing the cross product vector(s). Ignored if both input vectors have ... Read More
![AmitDiwan](https://www.tutorialspoint.com/assets/profiles/123055/profile/60_187394-1565938756.jpg)
64 Views
To return the scaled companion matrix of a 1-D array of polynomial coefficients, return the hermite.hermcompanion() method in Python Numpy. The basis polynomials are scaled so that the companion matrix is symmetric when c is an Hermite basis polynomial. This provides better eigenvalue estimates than the unscaled case and for basis polynomials the eigenvalues are guaranteed to be real if numpy.linalg.eigvalsh is used to obtain them. The method returns the Scaled companion matrix of dimensions (deg, deg). The parameter, c is a 1-D array of Hermite series coefficients ordered from low to high degree.StepsAt first, import the required library −import ... Read More
![AmitDiwan](https://www.tutorialspoint.com/assets/profiles/123055/profile/60_187394-1565938756.jpg)
91 Views
To generate a pseudo Vandermonde matrix of the Hermite polynomial and x, y, z sample points, use the hermite.hermvander3d() in Python Numpy. The method returns the pseudo-Vandermonde matrix. The parameter, x, y, z are arrays of point coordinates, all of the same shape. The dtypes will be converted to either float64 or complex128 depending on whether any of the elements are complex. Scalars are converted to 1-D arrays. The parameter, deg is the list of maximum degrees of the form [x_deg, y_deg, z_deg].StepsAt first, import the required library −numpy as np from numpy.polynomial import hermite as HCreate arrays of point ... Read More
![AmitDiwan](https://www.tutorialspoint.com/assets/profiles/123055/profile/60_187394-1565938756.jpg)
250 Views
The gradient is computed using second order accurate central differences in the interior points and either first or second order accurate one-sides (forward or backwards) differences at the boundaries. The returned gradient hence has the same shape as the input array. The 1st parameter, f is an Ndimensional array containing samples of a scalar function. The 2nd parameter is the varargs i.e. the spacing between f values. Default unitary spacing for all dimensions.The 3rd parameter is the edge_order{1, 2} i.e. the Gradient is calculated using N-th order accurate differences at the boundaries. Default: 1. The 4th parameter is the Gradient, ... Read More
![AmitDiwan](https://www.tutorialspoint.com/assets/profiles/123055/profile/60_187394-1565938756.jpg)
78 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 1st parameter is the input array. The 2nd parameter is n, i.e. the number of times values are differenced. If zero, the input is returned as-is. The 3rd parameter is the axis along which the difference is taken, default is the last axis.The 4th parameter is the values to prepend or append to the input array along axis prior to performing the difference. Scalar values are ... Read More
![AmitDiwan](https://www.tutorialspoint.com/assets/profiles/123055/profile/60_187394-1565938756.jpg)
3K+ Views
To return the real part of the complex argument, use the numpy.real() method. 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 array. We will also change the real part of the complex argument using the array.real.StepsAt first, import the required libraries-import numpy as npCreate an array using the array() method −arr = np.array([36.+1.j , 27.+2.j , 68.+3.j , 23.+2.j])Display the array −print("Our Array...", arr)Check the Dimensions −print("Dimensions of ... Read More