0

I am trying to build a basic number classifier in python, and I have a 3923 * 65 array. Each row in my array is an image that when showed is a number from 0 to 9. 3923 * 64 is the actual size of my array, and the last column is the actual number the image is. I already have an array for the entire 3923 * 65, and one for the 3923 * 64 part of it. full array:

fullImageArray = np.zeros((len(myImageList),65), dtype = np.float64)
fullImageArray = np.array(myImageList)

number array:

fullPlotArray = np.zeros((len(myImageList),64), dtype = np.float64)
fullPlotArray = np.array(fullImageArray)
fullPlotArray.resize(len(myImageList),64)

How do I make an array of only the last column?

1 Answer 1

6

You can create views of your data by slicing the array:

full_array = np.array(myImageList)
plot_array = full_array[:, :64]  # First 64 columns of full_array
last_column = full_array[:, -1]

The results will be views into the same data as the original array; no copy is created. changing the last column of full_array is the same as changing last_column, since they are pointing to the same data in memory.

See the Numpy documentation on indexing and slicing for further information.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.