numpy.ma.flatnotmasked_edges() function | Python

numpy.ma.flatnotmasked_edges() function find the indices of the first and last unmasked values.

Syntax : numpy.ma.flatnotmasked_edges(arr)

Parameters :
arr : [ array_like] Input 1-D MaskedArray.

Return : [ndarray or None] The indices of first and last non-masked value in the array. Returns None if all values are masked.

Code #1 :



filter_none

edit
close

play_arrow

link
brightness_4
code

# Python program explaining
# numpy.ma.flatnotmasked_edges() function
  
# importing numpy as geek  
# and numpy.ma module as ma 
import numpy as geek 
import numpy.ma as ma 
  
arr = geek.ma.arange(12)
  
gfg = geek.ma.flatnotmasked_edges(arr)
  
print (gfg)

chevron_right


Output :

[ 0, 11]

 
Code #2 :

filter_none

edit
close

play_arrow

link
brightness_4
code

# Python program explaining
# numpy.ma.flatnotmasked_edges() function
  
# importing numpy as geek  
# and numpy.ma module as ma 
import numpy as geek 
import numpy.ma as ma 
  
arr = geek.ma.arange(12)
arr[:] = geek.ma.masked
  
gfg = geek.ma.flatnotmasked_edges(arr)
  
print (gfg)

chevron_right


Output :

None
My Personal Notes arrow_drop_up

Check out this Author's contributed articles.

If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to contribute@geeksforgeeks.org. See your article appearing on the GeeksforGeeks main page and help other Geeks.

Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.


Article Tags :

Be the First to upvote.


Please write to us at contribute@geeksforgeeks.org to report any issue with the above content.