python numpy.array插入一行或一列 对python numpy.array插入一行或一列的方法详解

软件发布|下载排行|最新软件

当前位置:首页IT学院IT技术

python numpy.array插入一行或一列 对python numpy.array插入一行或一列的方法详解

易_   2021-03-30 我要评论

如下所示:

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]]
 

以上这篇对python numpy.array插入一行或一列的方法详解就是小编分享给大家的全部内容了,希望能给大家一个参考,也希望大家多多支持。

猜您喜欢

Copyright 2022 版权所有 软件发布 访问手机版

声明:所有软件和文章来自软件开发商或者作者 如有异议 请与本站联系 联系我们