I understand how to create a mask in a mask, and I would like to use masking in an array of records so that I can access this data using named attributes. Masking seems "lost" when I create an array of records from a masked array:
>>> data = np.ma.array(np.ma.zeros(30, dtype=[('date', '|O4'), ('price', '<f8')]),mask=[i<10 for i in range(30)]) >>> data masked_array(data = [(--, --) (--, --) (--, --) (--, --) (--, --) (--, --) (--, --) (--, --) (--, --) (--, --) (0, 0.0) (0, 0.0) (0, 0.0) (0, 0.0) (0, 0.0) (0, 0.0) (0, 0.0) (0, 0.0) (0, 0.0) (0, 0.0) (0, 0.0) (0, 0.0) (0, 0.0) (0, 0.0) (0, 0.0) (0, 0.0) (0, 0.0) (0, 0.0) (0, 0.0) (0, 0.0)], mask = [(True, True) (True, True) (True, True) (True, True) (True, True) (True, True) (True, True) (True, True) (True, True) (True, True) (False, False) (False, False) (False, False) (False, False) (False, False) (False, False) (False, False) (False, False) (False, False) (False, False) (False, False) (False, False) (False, False) (False, False) (False, False) (False, False) (False, False) (False, False) (False, False) (False, False)], fill_value = ('?', 1e+20), dtype = [('date', '|O4'), ('price', '<f8')]) >>> r = data.view(np.recarray) >>> r rec.array([(0, 0.0), (0, 0.0), (0, 0.0), (0, 0.0), (0, 0.0), (0, 0.0), (0, 0.0), (0, 0.0), (0, 0.0), (0, 0.0), (0, 0.0), (0, 0.0), (0, 0.0), (0, 0.0), (0, 0.0), (0, 0.0), (0, 0.0), (0, 0.0), (0, 0.0), (0, 0.0), (0, 0.0), (0, 0.0), (0, 0.0), (0, 0.0), (0, 0.0), (0, 0.0), (0, 0.0), (0, 0.0), (0, 0.0), (0, 0.0)], dtype=[('date', '|O4'), ('price', '<f8')])
When I access the record, the data is not masked:
>>> r.date[0] 0
Unlike the original array:
>>> data['date'][0] masked_array(data = --, mask = True, fill_value = 1e+20) fill_value = 1e+20)
What can I do? Does the array of records support masking? Browsing on the Internet I saw several code examples that seemed to offer otherwise, but that was not very clear. Hopefully I get a good answer here.