首先输入一个矩阵: b=[[1,2,3,4,5,6],[2,2,3,4,5,6],[3,2,3,4,5,6],[4,2,3,4,5,6],[5,2,3,4,5,6]] b=np.array(b) barray([[1, 2, 3, 4, 5, 6], [2, 2, 3, 4, 5, 6], [3, 2, 3, 4, 5, 6], [4, 2, 3, 4, 5, 6], [5, 2, 3, 4, 5, 6]]) 目标:取上述
首先输入一个矩阵:
>>> b=[[1,2,3,4,5,6],[2,2,3,4,5,6],[3,2,3,4,5,6],[4,2,3,4,5,6],[5,2,3,4,5,6]] >>> b=np.array(b) >>> b array([[1, 2, 3, 4, 5, 6], [2, 2, 3, 4, 5, 6], [3, 2, 3, 4, 5, 6], [4, 2, 3, 4, 5, 6], [5, 2, 3, 4, 5, 6]])
目标:取上述矩阵的2,3,4,5,6列
>>> e=b[:,1:len(b[0])] >>> e array([[2, 3, 4, 5, 6], [2, 3, 4, 5, 6], [2, 3, 4, 5, 6], [2, 3, 4, 5, 6], [2, 3, 4, 5, 6]])
以上这篇Python 实现取矩阵的部分列,保存为一个新的矩阵方法就是小编分享给大家的全部内容了,希望能给大家一个参考,也希望大家多多支持易盾网络。