I have the following array:
[[ 6. 105. 2. 8.09841881]
[ 6. 105. 4. 9.34220351]
[ 6. 105. 6. 9.97663435]
[ 6. 1001. 2. 9.57108242]
[ 6. 1001. 4. 12.22355794]
[ 6. 1001. 6. 13.57295942]
[ 12. 1001. 2. 12.37474466]
[ 12. 1001. 4. 17.45334004]
[ 12. 1001. 6. 19.88499289]
[ 18. 1007. 2. 16.09076561]
[ 18. 1007. 4. 23.43742275]
[ 18. 1007. 6. 27.73041646]]
And I have tried to extract only the rows with the first element being a six via
print ma.MaskedArray(a, mask=(np.ones_like(a)*(a[:,0]==6.0)).T)
which I got from the question " mask a 2D numpy array based on values in one column". However, I get
File "./Prova.py", line 170, in <module>
print ma.MaskedArray(a, mask=(np.ones_like(a)*(a[:,0]==6.0)).T)
ValueError: operands could not be broadcast together with shapes (12,4) (12)
do you have a clue of why this doesn't work?
The question might be stupid, but please bear with me since I just started programming python. :-)
np.newaxisinto your mask.