Analyze Data/Python Libraries

numpy-np.c_[] VS np.r_[]

Naranjito 2023. 5. 25. 17:02
  • np.r_[]

It concatenates arrays along first axis.

 

  • np.c_[]

It concatenates arrays along second axis.

a = np.array([[1, 2, 3],
              [11,22,33]]
            )
b = np.array([[4, 5, 6],
              [44,55,66]]
            )
                   
np.r_[a,b]
>>>
array([[ 1,  2,  3],
       [11, 22, 33],
       [ 4,  5,  6],
       [44, 55, 66]])
       
np.c_[a,b]
>>>
array([[ 1,  2,  3,  4,  5,  6],
       [11, 22, 33, 44, 55, 66]])

'Analyze Data > Python Libraries' 카테고리의 다른 글

numpy-identity  (0) 2023.06.02
numpy-linspace, interp  (0) 2023.05.30
numpy-axis, expand_dims  (0) 2023.05.24
numpy-random  (0) 2022.12.29
numpy-empty, where, allclose, dot, argsort, corrcoef, astype, nan, hstack, argmax  (0) 2022.12.07