Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

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?

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

>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]

Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading