I am trying to slice the columns of numpy array in python.
How to print all the columns except first one? Imagine I have large dimensions of numpy array not the simple one.
First, create an array in Python, then, use slicing to extract everything but the first column:
import numpy as np
a = np.array([[1,2,3], [4,5,6], [7,8,9]])
sliced = a[:,1:]
print(sliced)
output:
array([[2, 3],
[5, 6],
[8, 9]])
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