1

I have two numpy arrays (letters from the EMNIST dataset):

import scipy .io
emnist = scipy.io.loadmat(DATA_DIR + '/emnist-letters.mat')
data = emnist ['dataset']
X_train = data ['train'][0, 0]['images'][0, 0]
y_train = data ['train'][0, 0]['labels'][0, 0]

With the following dimensions:

X_train.shape = (124800, 784)

y_train.shape = (124800, 1)

Now, I want to concatenate the two, so that the new shape would be: (124800, 785).

Based on this link, I tried:

np.concatenate((X_train.shape, y_train.shape), axis = 0)

However, that results in the following shape: array([124800, 784, 124800, 1]).

How can I 'paste' y_train behind X_train so that the shape will be (124800, 785)?

1 Answer 1

1

If you concatenate two arrays, you have to concatenate the data inside the arrays, not the shape. Furthermore you want to concatenate on the second ("short") axis, which is axis=1:

np.concatenate((X_train, y_train), axis=1)
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.