You can call yourrecarray.resize with a form that has another line, and then assign this new line. Of course. numpy will still have to allocate a whole new memory if it just doesnβt have room for the array to grow in place, but at least you have a chance! -)
Since the request was requested, here comes a change from the canonical list of examples ...:
>>> import numpy >>> mydescriptor = {'names': ('gender','age','weight'), 'formats': ('S1', 'f4', 'f4')} >>> a = numpy.array([('M',64.0,75.0),('F',25.0,60.0)], dtype=mydescriptor) >>> print a [('M', 64.0, 75.0) ('F', 25.0, 60.0)] >>> a.shape (2,) >>> a.resize(3) >>> a.shape (3,) >>> print a [('M', 64.0, 75.0) ('F', 25.0, 60.0) ('', 0.0, 0.0)] >>> a[2] = ('X', 17.0, 61.5) >>> print a [('M', 64.0, 75.0) ('F', 25.0, 60.0) ('X', 17.0, 61.5)]
Alex martelli
source share