对python numpy.array插入一行或一列的方法详解
时间:2021-05-19 09:41:46|栏目:Python代码|点击: 次
如下所示:
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]]
上一篇:pandas获取groupby分组里最大值所在的行方法
栏 目:Python代码
本文标题:对python numpy.array插入一行或一列的方法详解
本文地址:http://www.codeinn.net/misctech/124668.html






