Note
Numpy (9) 본문
728x90
How to stack two arrays horizontally?
a = np.arange(10).reshape(2,-1)
b = np.repeat(1, 10).reshape(2,-1)
# Answers
# 1:
np.concatenate([a, b], axis=1)
# 2:
np.hstack([a, b])
# 3:
np.c_[a, b]
# output
array([[0, 1, 2, 3, 4, 1, 1, 1, 1, 1],
[5, 6, 7, 8, 9, 1, 1, 1, 1, 1]])
'Numpy' 카테고리의 다른 글
Numpy (11) (0) | 2022.07.31 |
---|---|
Numpy (10) (0) | 2022.07.30 |
Numpy (8) (0) | 2022.07.28 |
Numpy (7) (0) | 2022.07.27 |
Numpy (6) (0) | 2022.07.26 |
Comments