Alter the masked value symbol - - when printing a masked Numpy array

后端 未结 1 964
醉话见心
醉话见心 2020-12-21 23:21

I am looking for a way to alter the -- masked value symbol when printing a masked Numpy array

相关标签:
1条回答
  • 2020-12-21 23:36

    Poking around in the np.ma module, and the methods of a masked array I found

    np.ma.masked_print_option
    "Handle the string used to represent missing data in a masked array."
    

    The default '--':

    In [619]: np.ma.masked_print_option.display()
    Out[619]: '--'
    

    changed to 'xx'

    In [620]: np.ma.masked_print_option.set_display('xx')
    
    In [621]: M
    Out[621]: 
    masked_array(data = [0 xx 2 xx 4 xx 6 xx 8 xx],
                 mask = [False  True False  True False  True False  True False  True],
           fill_value = 999999)
    
    0 讨论(0)
提交回复
热议问题