Note
Numpy (8) 본문
728x90
How to stack two arrays vertically?
a = np.arange(10).reshape(2,-1)
b = np.repeat(1, 10).reshape(2,-1)
# Answers
# 1:
np.concatenate([a, b], axis=0)
# 2:
np.vstack([a, b])
# 3:
np.r_[a, b]
# output
array([[0, 1, 2, 3, 4],
[5, 6, 7, 8, 9],
[1, 1, 1, 1, 1],
[1, 1, 1, 1, 1]])
Comments