Data Structure
Networking
RDBMS
Operating System
Java
MS Excel
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
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
Server Side Programming Articles - Page 664 of 2650
175 Views
To suppress the rows and/or columns of a 2-D array that contain masked values, use the np.ma.mask_compress_rowcols() method in Numpy. The suppression behavior is selected with the axis parameter.If axis is None, both rows and columns are suppressed.If axis is 0, only rows are suppressed.If axis is 1 or -1, only columns are suppressed.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
154 Views
To suppress whole rows of a 2-D array that contain masked values, use the np.ma.mask_compress_rows() method in 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 maCreate an array with int elements using the numpy.array() method −arr = np.array([[65, 68, 81], [93, 33, 39], [73, 88, 51], ... Read More
259 Views
To convert inputs to arrays with at least three dimensions, use the ma.atleast_3d() method in Python Numpy. The parameters are one or more array-like sequences. Non-array inputs are converted to arrays. Arrays that already have three or more dimensions are preserved.The function returns an array, or list of arrays, each with a.ndim >= 3. Copies are avoided where possible, and views with three or more dimensions are returned. For example, a 1-D array of shape (N, ) becomes a view of shape (1, N, 1), and a 2-D array of shape (M, N) becomes a view of shape (M, N, ... Read More
146 Views
To suppress whole columns of a 2-D array that contain masked values, use the np.ma.mask_compress_cols() method in 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 maCreate an array with int elements using the numpy.array() method −arr = np.array([[65, 68, 81], [93, 33, 39], [73, 88, 51], ... Read More
5K+ Views
To mask an array where a condition is met, use the numpy.ma.masked_where() method in Python Numpy. Return the array to mask as an array masked where condition is True. Any masked values of a or condition are also masked in the output.The condition parameter sets the masking condition. When condition tests floating point values for equality, consider using masked_values instead. The copy parameter, If True (default) make a copy of a in the result. If False modify a in place and return a view.StepsAt first, import the required library −import numpy as np import numpy.ma as maCreate an array with ... Read More
461 Views
To mask using floating point equality, use the numpy.ma.masked_values() method in Python Numpy. Return a MaskedArray, masked where the data in array x are approximately equal to value, determined using isclose. The default tolerances for masked_values are the same as those for isclose.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 ... Read More
252 Views
To mask an array outside a given interval, use the numpy.ma.masked_outside() method in Python Numpy. Shortcut to masked_where, where condition is True for x outside the interval [v1, v2] (x < v1)|(x > v2). The boundaries v1 and v2 can be given in either order.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 ... Read More
861 Views
To mask an array where the data is exactly equal to value, use the numpy.ma.masked_object() method in Python Numpy. This function is similar to masked_values, but only suitable for object arrays: for floating point, use masked_values instead.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 maCreate an array ... Read More
490 Views
To mask an array where not equal to a given value, use the numpy.ma.masked_not_equal() method in Python Numpy. This function is a shortcut to masked_where, with condition = (x != value).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 maCreate an array with int elements using the numpy.array() ... Read More
2K+ Views
To mask an array where invalid values occur (NaNs or infs), use the numpy.ma.masked_invalid() method in Python Numpy. This function is a shortcut to masked_where, with condition = ~(np.isfinite(a)). Any pre-existing mask is conserved. Only applies to arrays with a dtype where NaNs or infs make sense (i.e. floating point types), but accepts any array_like object.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 ... Read More