2
想要選擇1和4之間的數據,並將其他數據轉換爲np.nan 但是,解決方案是什麼?從numpy數組中選擇所需的數據
import numpy as np
data = np.array([1,2,3,4,5])
selected = np.where(1<data<4, data, np.nan)
print (selected)
Traceback (most recent call last):
File "C:/Users/fe/Desktop/t.py", line 3, in <module>
selected = np.where(1<data<4, data, np.nan)
ValueError: The truth value of an array with more than one element is ambiguous. Use a.any() or a.all()