1

I have an array with a sequence of integers like this:

import numpy as np
a1 = np.zeros((1, 100000))
a2 = np.arange(-50, 50+1)
#so a2 looks like this
a2 = [-50, -49, ....., -1, 0, 1, ...., 49, 50]

how can i add the sequence of a2, to a1 multiple times in a row?

1
  • Give an example of how your output should look like. Commented Apr 3, 2020 at 7:40

1 Answer 1

1

You can tile numpy arrays:

a1 = np.zeros((1, 100000))
a2 = np.arange(-50, 50+1)
a1 += np.tile(a2, 1000)[:100000]

print(len(a1), repr(a1))

It gives:

100000 array([-50, -49, -48, ..., -43, -42, -41])
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.