python - removing rows from an array if first entry in row is particular string -
i want remove rows array y have 'copy' first entry
i tried this
for in range(len(y)-1): if y[i][0] == 'copy': n.delete(y,i,0)
i don't error rows haven't been deleted when print y.
i tried
y[y[:,0] != 'copy']
but error
indexerror traceback (most recent call last) <ipython-input-36-b03bdf03aa31> in <module>() ----> 1 y[y[:,0] != 'copy'] indexerror: many indices
if explain why not working , suggest solution appreciated
thanks
with list comprehension:
[x x in y if x[0] != 'copy']
with filter()
, lambda:
list(filter(lambda x: x[0] != 'copy', y))
Comments
Post a Comment