1

I have a simple question here, I have three arrays,

a = np.array([1,2,3])
b = np.array([4,5,6])
c = np.array([7,8,9])
d = np.array([6,6,6])

I combine a,b,c to another array say e,

e = np.array([a,b,c])

I want d to be inserted to e so that I get the following output,

[[1, 2, 3], [4, 5, 6], [7, 8, 9], [6,6,6]]

1 Answer 1

2

Use numpy.append that appends to the end of array:

e = np.append(e, [d], axis=0)

Note as quoted from docs:

Append values to the end of an array. When axis is specified, values must have the correct shape.

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.