Numpy

Numpy (10)

알 수 없는 사용자 2022. 7. 30. 19:58
728x90

How to generate custom sequences in numpy without hardcoding?

a = np.array([1,2,3])

np.r_[np.repeat(a, 3), np.tile(a, 3)]

# output
array([1, 1, 1, 2, 2, 2, 3, 3, 3, 1, 2, 3, 1, 2, 3, 1, 2, 3])