0

I'm trying to create one array which is a sequence of the following numpy arrays: np.random.normal([0, 0], size=(500, 2)), np.random.normal([5, 5], size=(500, 2)), np.random.normal([5, 0], size=(500, 2)), np.random.normal([0, 5], size=(500, 2)) How can I merge them into one? Tnx!

I tried using + operator but didn't work.

3
  • + is multiply for numpy arrays. For lists (and strings) it is join. Commented Jan 24, 2023 at 17:58
  • Do you want a [500, 8] or do you want [2000, 2]? Commented Jan 24, 2023 at 17:59
  • I wanted [2000, 2]. Commented Jan 25, 2023 at 10:07

1 Answer 1

1

You can use the numpy concatenate() method to combine multiple arrays into one.

The syntax would be:

np.concatenate([np.random.normal([0, 0], size=(500, 2)), np.random.normal([5, 5], size=(500, 2)), np.random.normal([5, 0], size=(500, 2)), np.random.normal([0, 5], size=(500, 2))])

Hope this will solve your issue

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.