7
我一直試圖使用python的numpy.where
函數來確定特定值的位置,但由於某種原因,它錯誤地確定了False
其中實際找到的值。從而返回一個空數組。見下:Numpy.where函數沒有在數組中找到值...任何人都知道爲什麼?
>>>lbpoly=numpy.array([ 5.45 5.5 5.55 5.6 5.65 5.7 5.75 5.8 5.85 5.9 5.95 6.
6.05 6.1 6.15 6.2 6.25 6.3 6.35 6.4 6.45 6.5 6.55 6.6
6.65 6.7 6.75 6.8 6.85 6.9 6.95 7. ])
>>>cpah=numpy.where(lbpoly==6.2)
>>>print cpah
>>>(array([], dtype=int32),)
有沒有人知道爲什麼會發生這種情況?我已經嘗試了許多不同的變體,甚至使用<
和>
邏輯。但是這會產生2個值的指數。
是你'lbpoly'一個numpy的陣列?看起來像一個列表。 – dede
列表以逗號,不帶(通常)的數組形式顯示。 – hpaulj
@dede是的,這是一個數組。在我的匆忙中,我錯誤地將它放在這裏看起來像一個列表。 – Lawrence