Skip to content
Related Articles

Related Articles

Improve Article

numpy.ma.flatnotmasked_edges() function | Python

  • Last Updated : 22 Apr, 2020
Geek Week

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 :






# 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)

Output :

[ 0, 11]

 
Code #2 :




# 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)

Output :

None

 Attention geek! Strengthen your foundations with the Python Programming Foundation Course and learn the basics.  

To begin with, your interview preparations Enhance your Data Structures concepts with the Python DS Course. And to begin with your Machine Learning Journey, join the Machine Learning – Basic Level Course




My Personal Notes arrow_drop_up
Recommended Articles
Page :