I’m trying to remove an observation in an array via indexing. What I have is:
import numpy as np
test = np.ones([1, 1001])
What I want to do is return an array that is the same as test, but having removed the 5th observation (ie, test[0:4 AND 6:]). Is there a simple way to do this?
You could use slicing and
hstack:Note that your indexing is off by one:
test[0:4 AND 6:]would delete two elements instead of one.