Functions for adding columns and rows to numpy arrays: column_stack, row_stack, functions for deleting rows or columns, delete

 def fun_ndarray():
      a = [[1,2,7],
           [-6,-2,-3],
           [-4,-8,-55]
           ]
      b = [3,5,6]
      a = np.array(a)
      b = np.array(b)
      a_b_column = np.column_stack((a,b))#左右根据列拼接
      a_b_row = np.row_stack((a,b))#上下按照行拼接 
      print('a_b_column')
      print(a_b_column)
      print('a_b_row')
      print(a_b_row)

result:

note:

column_stack, row_stack function parameter is a tuple

np.delete(): delete a row or column

data = np.delete(data,3,axis=1) # 删除第四列

 

Undertake programming in Matlab, Python and C++, machine learning, computer vision theory implementation and guidance, both undergraduate and master's degree, salted fish trading, professional answers please go to know, please contact QQ number 757160542 for details, if you are the one.

 

 

 

Guess you like

Origin blog.csdn.net/weixin_36670529/article/details/113817932