【发布时间】:2023-01-31 20:21:17
【问题描述】:
我有一个数组(称为“吸引子”),如下所示:
[['0000000000' '0.0' '0.0']
['0000000001' '0.0' '1.0']
['0000000010' '0.0' '2.0']
...........................
我想创建一个新数组,其中包含原始数组中第三列为 0 的所有行。我尝试以下操作:
print(attractors[attractors[: , 2] == 0][: , 0])
但我收到以下错误:
json export to visualize state transition diagram with compression
- tests.py:247: FutureWarning: elementwise comparison failed;
returning scalar instead, but in the
future will perform elementwise comparison
print(attractors[attractors[: , 2] == 0][: , 0])
如果我在条件上加上括号,就像这样:
print(attractors[attractors[: , 2] == "0"][: , 0])
然后错误没有出现,但是结果不是我预期的(只有空括号[])
【问题讨论】:
标签: python numpy-ndarray