- 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
274 Views
To return the indices of unmasked elements that are not zero, use the ma.MaskedArray.nonzero() method in Numpy. To group the indices by element, we have used the nonzero() method in the transpose().Returns a tuple of arrays, one for each dimension, containing the indices of the non-zero elements in that dimension. The corresponding non-zero values can be obtained with −a[a.nonzero()]To group the indices by element, rather than dimension, use instead −np.transpose(a.nonzero()) The result of this is always a 2d array, with a row for each non-zero element.StepsAt first, import the required library −import numpy as np import numpy.ma as maCreate an ... Read More
179 Views
To return the indices of unmasked elements that are not zero, use the ma.MaskedArray.nonzero()Returns a tuple of arrays, one for each dimension, containing the indices of the non-zero elements in that dimension. The corresponding non-zero values can be obtained with −a[a.nonzero()]To group the indices by element, rather than dimension, use instead −np.transpose(a.nonzero()) The result of this is always a 2d array, with a row for each non-zero element.StepsAt first, import the required library −import numpy as np import numpy.ma as maCreate an array with int elements using the numpy.array() method −arr = np.array([[55, 85, 59, 77], [67, 33, 39, 57], ... Read More
812 Views
To subtract a scalar value from every element of a masked Array, use the ma.MaskedArray.__sub__() method in Python Numpy. A masked array is the combination of a standard numpy.ndarray and a mask. A mask is either nomask, indicating that no value of the associated array is invalid, or an array of booleans that determines for each element of the associated array whether the value is valid or not.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 ... Read More
191 Views
To add a scalar value to each element and return a new masked array, use the ma.MaskedArray.__radd__() method in Python Numpy. A masked array is the combination of a standard numpy.ndarray and a mask. A mask is either nomask, indicating that no value of the associated array is invalid, or an array of booleans that determines for each element of the associated array whether the value is valid or not.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, ... Read More
109 Views
To sort the masked array in-place, use the ma.MaskedArray.sort() method in Numpy. The axis parameter sets the axis along which to sort. The axis value is set 1.The method returns an array of the same type and shape as array. When the array is a structured array, the order parameter specifies which fields to compare first, second, and so on. This list does not need to include all of the fields.The endwith parameter, suggests whether missing values (if any) should be treated as the largest values (True) or the smallest values (False) When the array contains unmasked values sorting at ... Read More
121 Views
To add each and every element of a masked array with a scalar value val, use the ma.MaskedArray.__add__() method. Returns the array with the value val added to every element. A masked array is the combination of a standard numpy.ndarray and a mask. A mask is either nomask, indicating that no value of the associated array is invalid, or an array of booleans that determines for each element of the associated array whether the value is valid or not.NumPy offers comprehensive mathematical functions, random number generators, linear algebra routines, Fourier transforms, and more. It supports a wide range of hardware ... Read More
209 Views
To return the absolute value of a masked Array, use the ma.MaskedArray.__abs__() method. If the element is negative, the abs() method negates it and returns. A masked array is the combination of a standard numpy.ndarray and a mask. A mask is either nomask, indicating that no value of the associated array is invalid, or an array of booleans that determines for each element of the associated array whether the value is valid or not.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 ... Read More
95 Views
To check which element in a masked array is not equal to a given value, use the ma.MaskedArray.__ne__() method. True is returned for every array element not equal to a given value val. A masked array is the combination of a standard numpy.ndarray and a mask. A mask is either nomask, indicating that no value of the associated array is invalid, or an array of booleans that determines for each element of the associated array whether the value is valid or not.NumPy offers comprehensive mathematical functions, random number generators, linear algebra routines, Fourier transforms, and more. It supports a wide ... Read More
93 Views
To check which element in a masked array is equal to a given value, use the ma.MaskedArray.__eq__() method. True is returned for every array element equal to a given value val. A masked array is the combination of a standard numpy.ndarray and a mask. A mask is either nomask, indicating that no value of the associated array is invalid, or an array of booleans that determines for each element of the associated array whether the value is valid or not.NumPy offers comprehensive mathematical functions, random number generators, linear algebra routines, Fourier transforms, and more. It supports a wide range of ... Read More
114 Views
To check which element in a masked array is greater than or equal to a given value, use the ma.MaskedArray.__ge__() method. True is returned for every array element greater than or equal to a given value val. A masked array is the combination of a standard numpy.ndarray and a mask. A mask is either nomask, indicating that no value of the associated array is invalid, or an array of booleans that determines for each element of the associated array whether the value is valid or not.NumPy offers comprehensive mathematical functions, random number generators, linear algebra routines, Fourier transforms, and more. ... Read More