adrin adrin - 1 year ago 299
Python Question

How to exclude rows/columns from numpy.ndarray data

Assume we have a numpy.ndarray data, let say with the shape (100,200), and you also have a list of indices which you want to exclude from the data. How would you do that? Something like this:

a = numpy.random.rand(100,200)
indices = numpy.random.randint(100,size=20)
b = a[-indices,:] # imaginary code, what to replace here?


Answer Source

You can use b = numpy.delete(a, indices, axis=0)


Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download