Добавление строки к numpy recarray

Попробуйте его этот путь:

$("table:first").find("tr:first").find("td:first").find("a:first").click();

, Который инициирует onclick событие первое в первой ячейке первой строки в первой таблице... и его очень читаемом сам по себе.

6
задан astrofrog 21 October 2009 в 01:14
поделиться

1 ответ

You can call yourrecarray.resize with a shape which has one more row, then assign to that new row. Of course. numpy might still have to allocate completely new memory if it just doesn't have room to grow the array in-place, but at least you stand a chance!-)

Since an example was requested, here comes, modified off the canonical example list...:

>>> 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)]
10
ответ дан 10 December 2019 в 00:40
поделиться
Другие вопросы по тегам:

Похожие вопросы: