- 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
436 Views
To compare and return True if an array is greater than another array, use the numpy.char.greater() 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 npCreate two One-Dimensional arrays of string −arr1 = np.array(['Bella', 'Tom', 'John', 'Kate', 'Amy', 'Brad', 'aaa']) arr2 = np.array(['Cio', 'Tom', 'Cena', 'Kate', 'Adams', 'brad', 'aa'])Display the arrays −print("Array 1...", arr1) print("Array 2...", arr2)Get the type of the arrays −print("Our ... Read More
89 Views
To compute the bit-wise OR of two 1D arrays element-wise, use the numpy.bitwise_or() method in Python Numpy. Computes the bit-wise OR of the underlying binary representation of the integers in the input arrays. This ufunc implements the C/Python operator |.The 1st and 2nd parameter are the arrays, only integer and boolean types are handled. If x1.shape != x2.shape, they must be broadcastable to a common shape.The where parameter is the condition broadcast over the input. At locations where the condition is True, the out array will be set to the ufunc result. Elsewhere, the out array will retain its original ... Read More
176 Views
To return the underlying data, as a view of the masked array, use the ma.MaskedArray.data 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.StepsAt first, import the required library −import numpy as np import numpy.ma as maCreating a 4x4 array with int elements using the numpy.arange() method −arr = np.arange(16).reshape((4, 4)) print("Array...", arr) print("Array type...", arr.dtype)Get the dimensions ... Read More
1K+ Views
To return the mask of a masked array, use the ma.getmask() method in Python Numpy. Returns the mask of a as an ndarray if a is a MaskedArray and the mask is not nomask, else return nomask. To guarantee a full array of booleans of the same shape as a, use getmaskarray.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.StepsAt ... Read More
104 Views
To count the number of masked elements along axis 1, use the ma.MaskedArray.count_masked() method. The axis is set using the "axis" parameter. The method returns the total number of masked elements (axis=None) or the number of masked elements along each slice of the given axis.The axis parameter is the axis along which to count. If None (default), a flattened version of the array is used.StepsAt first, import the required library −import numpy as np import numpy.ma as maCreating a 4x4 array with int elements using the numpy.arange() method −arr = np.arange(16).reshape((4, 4)) print("Array...", arr) print("Array type...", arr.dtype)Get the dimensions of ... Read More
109 Views
To compute the bit-wise OR of two arrays element-wise, use the numpy.bitwise_or() method in Python Numpy. Computes the bit-wise OR of the underlying binary representation of the integers in the input arrays. This ufunc implements the C/Python operator |.The 1st and 2nd parameter are the arrays, only integer and boolean types are handled. If x1.shape != x2.shape, they must be broadcastable to a common shape.The where parameter is the condition broadcast over the input. At locations where the condition is True, the out array will be set to the ufunc result. Elsewhere, the out array will retain its original value. ... Read More
325 Views
To return the mask of a masked array, or full boolean array of False, use the ma.getmaskarray() method in Python Numpy. Returns the mask of arr as an ndarray if arr is a MaskedArray and the mask is not nomask, else return a full boolean array of False of the same shape as arr.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 ... Read More
69 Views
To compute the bit-wise AND of a 1D and a 0D array element-wise, use the numpy.bitwise_and() method in Python Numpy. Computes the bit-wise AND of the underlying binary representation of the integers in the input arrays. This ufunc implements the C/Python operator &.The 1st and 2nd parameter are the arrays, only integer and boolean types are handled. If x1.shape != x2.shape, they must be broadcastable to a common shape. The where parameter is the condition broadcast over the input. At locations where the condition is True, the out array will be set to the ufunc result. Elsewhere, the out array ... Read More
153 Views
To return the data of a masked array as an ndarray, use the ma.getdata() method in Python Numpy. Returns the data of a (if any) as an ndarray if a is a MaskedArray, else return a as a ndarray or subclass if not.The subok parameter suggest whether to force the output to be a pure ndarray (False) or to return a subclass of ndarray if appropriate (True, default).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 ... Read More
87 Views
To return the mask of a masked array, use the ma.getmaskarray() method in Python Numpy. Returns the mask of arr as an ndarray if arr is a MaskedArray and the mask is not nomask, else return a full boolean array of False of the same shape as arr.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.StepsAt first, import the required ... Read More