Selecting first n elemets of a numpy array

I’m trying to get the first 784 elements of a numpy array. Is there a way to this? I tried doing array = array[:783], but that doesn’t seem to work. I also tried converting it to a list and then back to a numpy array like this

python_list = numpy_array.tolist()
cut_numpy_array = np.array(python_list[:783])

but that also doesn’t seem to work. Is there a way to do this?

>Solution :

If you are working with 2D array then you have to give starting and ending point of rows and starting and ending point of columns.
value = image[starting:ending, starting:ending]

Leave a Reply