I have a numpy array as "data". I want to retrieve all its field except the 6th field. Currently I am using following code:
x = data[:,[0,1,2,3,4,5,7,8,9,10,11,12,13,14,15,16,17]]
which is solving the purpose, but I feel it is not the correct way.
I tried many other ways to do it, like:
x = data[:, [:,6 and 7,:]],
x = data[:, [:,6 or 7,:]], etc
but nothing seems to be working.
I also checked at several other places, but could not find any solution. Please suggest some easy way to do it.
For a more general answer (if you need to discard several columns):
import numpy
x = numpy.array(data)[:,range(0,6)+range(7,18)]
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With