numpy.MaskedArray.masked_invalid() is used to mask an array containing invalid values (NaNs or infs). This function is a shortcut to
condition = ~ (numpy.isfinite (arr)) .
numpy.ma.masked_invalid (arr, copy = True)
arr: [ndarray] Input array which we want to mask.
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:
Input array: [1.2 . nan -1. inf] Masked array: [1.0 2.0 - -1.0 -]
Code # 2:
| tr> |
Input array: [5.e + 08 3.e-05 nan 4 .e + 04 5.e + 02] Masked array: [500000000.0 3e-05 - 40000.0 500.0]
In the summer of 2008, after three decades of building software in corporate data centers, I walked away from corporate America to take a stab at building a technology company from the ground up based...
Coding for Kids: Python - Learn to Code with 50 Awesome Games and Activities. Learning to code isn't as difficult as it sounds, you just have to get started! Coding for Kids: Python gets kids start...
For many decades, some powerful trends have been in place. Computer hardware has rap- idly been getting faster, cheaper and smaller. Internet bandwidth (that is, its information carrying capacity) has...
The rate at which we produce data is growing steadily, thus creating even larger streams of continuously evolving data. Online news, micro-blogs, search queries are just a few examples of these contin...