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

结果:

numpy 数组增加列,增加行的函数:column_stack,row_stack,删除行或列的函数,delete

note:

column_stack,row_stack函数参数是一个元组

np.delete():删除行或列

 

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

 

相关文章:

  • 2021-11-03
  • 2021-07-16
  • 2021-11-03
  • 2022-12-23
  • 2021-12-10
  • 2021-11-14
  • 2022-01-10
猜你喜欢
  • 2021-11-18
  • 2021-11-30
  • 2021-11-30
  • 2022-02-18
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
相关资源
相似解决方案