I have an array :
e = np.array([[ 0, 1, 2, 3, 4, 7, 4],
[ 4, 5, 6, 7, 2, 3, 1],
[ 8, 9, 10, 11, 3, 5, 7]])
I want to remove the range of columns from column 1 to column 3, so it should return:
e = np.array([[ 0, 4, 7, 4],
[ 4, 2, 3, 1],
[ 8, 3, 5, 7]])
I've seen some solution , but they remove specific column by its index, not in range, how to solve it? Thanks
Solved it using :
np.delete(e,np.s_[1:3],axis=1)
It will delete column in range 1 until 3.
e = np.array([[ 0, 1, 2, 3, 4, 7, 4],
[ 4, 5, 6, 7, 2, 3, 1],
[ 8, 9, 10, 11, 3, 5, 7]])
np.delete(e, [1,3], axis=1)
>>>array([[ 0, 2, 4, 7, 4],
[ 4, 6, 2, 3, 1],
[ 8, 10, 3, 5, 7]])
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