2016-07-29 7 views
2

Ich habe ein Problem, wo ich eine Warnung halten Empfang besagt:Visible deprecation Warnung auf numpy Array boolean Betrieb mit

VisibleDeprecationWarning: boolean index did not match indexed array along dimension 0; 
dimension is 744 but corresponding boolean dimension is 1 

Wenn ich versuche, dies zu nutzen:

x_low = xcontacts[(xcontacts[5:6] <= 2000).any(1), :] 
x_med = xcontacts[(xcontacts[5:6] <= 4000).any(1), :] 
x_med = xcontacts[(xcontacts[5:6] > 2000).any(1), :] 
x_hi = xcontacts[(xcontacts[5:6] > 4000).any(1), :] 

auf einem Array der Form:

xcontacts.shape 
Out[46]: (744L, 6L) 

Hier ist ein Beispiel der Anordnung:

[[ 1.  0.  0.  4.  0.  228.681 ] 
[ 2.  4.  0.  8.  0.  219.145 ] 
[ 3.  8.  0.  12.  0.  450.269 ] 
..., 
[ 60.  236.  96.  240.  96.  933.4565] 
[ 61.  240.  96.  244.  96.  646.449 ] 
[ 62.  244.  96.  248.  96.  533.657 ]] 

Ich versuche, drei neue Arrays zu erstellen, die Kopien der ersten sind aber nach einer Booleschen Operation auf der letzten Spalte, Entfernen Reihen durchgeführt worden, die mit dem Betreiber nicht einverstanden:

x_low where col5 <= 2000 
x_med where 2000 < col5 <= 4000 
x_hi where 4000 < col5 

Weiß jemand was ich falsch mache?

+2

sein sollte 'xcontacts [:, 5: 6] <= 2000' oder' xcontacts [:, 5] <= 2000'. Hinweis 'xcontacts [5: 6]' bedeutet 5. Zeile statt 5. Spalte. Aus diesem Grund stimmt die Form nicht überein und verursacht eine Warnung. –

Antwort

0

Dank @Syrtis-Dur für diese:

x_low = xcontacts[(xcontacts[:,5] <= 2000)] 
x_med = xcontacts[(xcontacts[:,5] <= 4000)] 
x_med = xcontacts[(xcontacts[:,5] > 2000)] 
x_hi = xcontacts[(xcontacts[:,5] > 4000)] 
Verwandte Themen