NumPy | Python Methods and Functions

** numpy.MaskedArray.masked_greater() ** is used to mask the array,

`numpy.MaskedArray.masked_greater()`

` masked_where `

with the condition ` = (arr & gt; value). `

Syntax:`numpy.ma.masked_greater (arr, value, copy = True)`

Parameters:

arr:[ ndarray] Input array which we want to mask.

value:[int] It is used to mask the array element which are & gt; value.

copy:[bool] If True (default) make a copy of arr in the result. If False modify arr in place and return a view.

Return:[MaskedArray] The resultant array after masking.

** Code # 1: **

` ` |

** Output:**

Input array: [1 2 3 -1 2 ] Masked array: [1 2 - -1 2]

** Code # 2: **

` `

` ` ` # Python program explaining `

` # numpy.MaskedArray.masked_greater () method `

` `

` # import numy as geek `

` # and numpy.ma module as ma `

` import `

` numpy as g eek `

` import `

` numpy.ma as ma `

` # create input array `

` in_arr `

` = `

` geek.array ([`

` 5e8 `

`, `

` 3e `

` - `

` 5 `

`, `

` - `

` 45.0 `

`, `

` 4e4 `

`, `

` 5e2 `

`]) `

` print `

` (`

` "Input array:" `

`, in_arr) `

` # applying MaskedArray.masked_greater methods `

` # to enter an array, where value & gt; 5e2 `

` mask_arr `

` = `

` ma.masked_greater ( in_arr, `

` 5e2 `

`) `

` print `

` (`

` "Masked array:" `

`, mask_arr) `

` `

** Output:**

Input array: [5.0e + 08 3.0e -05 -4.5e + 01 4.0e + 04 5.0e + 02] Masked array: [- 3e-05 -45.0 - 500.0]

ig Data applications are growing very rapidly around the globe. This new approach to decision making takes into account data gathered from multiple sources. Here my goal is to show how these diverse s...

10/07/2020

This is the first book on synthetic data for deep learning, and its extensive coverage could make this book the standard benchmark for synthetic data for years to come. The book can also serve as an i...

28/08/2021

In Learn Python 3 the Hard Way PDF, you'll learn Python by working through 52 brilliantly crafted exercises. Read them. Enter your code exactly. (No copying and pasting!) Correct your mistakes. ...

05/09/2021

During 2014, 2015, and 2016, surveys show that among all software developers, those with higher wages are the data engineers, the data scientists, and the data architects. This is because there is ...

10/07/2020

X
# Submit new EBook