-1

I have an array of binary elements size (100,).

I'd like to copy it 8 times, keeping the elements the same and store it as a new array size (800,)

np.copy() can copy it once, but how can I go about copying it 8 times?

3
  • 1
    Do you mean cycle through the elements 8 times or do you mean repeat each element 8 times and then move onto the next one? Commented Jul 25, 2020 at 20:09
  • 1
    Well here are the two options for the different cases I referred to above: np.tile(a, 8) for the first and np.repeat(a, 8) for the second. Commented Jul 25, 2020 at 20:13
  • 2
    Does this answer your question? stackoverflow.com/q/25471878/13552470 Commented Jul 25, 2020 at 20:24

1 Answer 1

2

You can use use numpy.repeat. It repeats array's elements by specifying repeat number:

new_arr = numpy.repeat(old_arr, 8)
Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.