我正在尝试将数组“ v”中的所有真值转换为它们的实际数字。任何建议将不胜感激。
import numpy as np
from numpy import load
dict_data = load('E_starData.npz')
EStar = dict_data['arr_0']
v = np.greater(EStar, 0.1)
print(v) #prints an array of true and false values, would like to display true values as the actual number
代码正在提取包含所有数据的已保存zip文件。
答案 0 :(得分:1)
您可以使用:
v = EStar * (EStar>0.1)
答案 1 :(得分:0)
从一开始就可能有更好的方法来解决该问题,但是要构建您的代码:
print([val for bool, val in zip(v, Estar) if bool])