numpy.array插入一行或一列

import numpy as np
a = np.array([[1,2,3],[4,5,6],[7,8,9]])
b = np.array([[0,0,0]])
c = np.insert(a, 0, values=b, axis=0)
d = np.insert(a, 0, values=b, axis=1)
print(c)
print(d)

结果:

>>c
[[0 0 0] 
[1 2 3] 
[4 5 6] 
[7 8 9]]
 
 
>>d
[[0 1 2 3] 
[0 4 5 6] 
[0 7 8 9]]
 

 

场景:df的字段名和数据添加到excel表

python numpy.array插入一行或一列

 

 

 

 

相关文章:

  • 2021-07-08
  • 2022-02-05
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-10-23
  • 2021-12-01
猜你喜欢
  • 2022-12-23
  • 2021-09-29
  • 2022-12-23
  • 2022-01-10
  • 2022-01-25
  • 2022-12-23
  • 2022-12-23
相关资源
相似解决方案