'NumPy concat by turns
How to combine 2 arrays by turns from
arr_1 = np.full((5,), 0)
arr_2 = np.full((5,), 1)
to
[0,1,0,1,0,1,0,1,0,1]
Thanks!
Solution 1:[1]
You can do that like so:
import numpy as np
a = np.array([0, 1])
repeated = np.tile(a, 5)
Result:
array([0, 1, 0, 1, 0, 1, 0, 1, 0, 1])
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | Nick ODell |
