下一个结构数组是numpy:
>>> matriz
rec.array([('b8:27:eb:07:65:ad', '0.130s', 255),
('b8:27:eb:07:65:ad', '0.120s', 215),
('b8:27:eb:07:65:ad', '0.130s', 168) ],
dtype=[('col1', '<U17'), ('col2', '<U17'), ('col3', '<i4'),
('col4','<U17')])
我需要在'col3'
中找到数字<;179,但我还需要打印数字所在的行
例如,在matriz
中,小于179的数字是168,那么我需要打印
('b8:27:eb:07:65:ad', '0.130s', 168)
是的
for j in matriz['col3']:
if j< 254:
print(j)
但是我只得到了int,知道吗
有人知道,如果有熊猫图书馆,我能做到吗
谢谢
这是一个1d数组,包含3个字段:
我们可以通过以下方式查看一个字段:
并获取其值的布尔掩码:
并使用该遮罩从整个数组中选择元素:
由于它是一个
rec.array
,而不仅仅是一个结构化数组,因此我们还可以将字段作为属性进行访问:您可以执行以下操作:
相关问题 更多 >
编程相关推荐