Python 实现取矩阵的部分列,保存为一个新的矩阵方法
作者:DeniuHe 时间:2023-07-17 23:22:30
首先输入一个矩阵:
>>> 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]])
来源:https://blog.csdn.net/DeniuHe/article/details/77414152
标签:Python,矩阵
![](/images/zang.png)
![](/images/jiucuo.png)
猜你喜欢
一文带你深入了解Go语言中切片的奥秘
2024-04-28 10:46:25
mysql索引必须了解的几个重要问题
2024-01-27 17:58:54
python数据分析之公交IC卡刷卡分析
2022-02-10 02:23:56
![](https://img.aspxhome.com/file/2023/5/75145_0s.png)
浅谈Python 函数式编程
2022-09-03 20:38:07
解决python问题 Traceback (most recent call last)
2021-10-31 06:17:49
![](https://img.aspxhome.com/file/2023/1/114631_0s.jpg)
python中List添加与删除元素的几种方法实例
2021-10-07 09:13:36
PHP脚本监控Nginx 502错误并自动重启php-fpm
2023-09-26 00:11:45
PHP生成器简单实例
2024-05-11 09:52:33
Python Django教程之实现待办事项应用程序
2022-11-13 09:39:15
![](https://img.aspxhome.com/file/2023/0/84870_0s.png)
Python如何获取文件路径/目录
2021-09-01 09:05:18
Java正则表达式的基本用法和实例大全
2023-04-14 06:17:22
![](https://img.aspxhome.com/file/2023/8/90028_0s.png)
MySQL 数据类型和建库策略
2024-01-20 12:32:40
Oracle 常用的SQL语句
2024-01-17 08:55:26
解决py2exe打包后,总是多显示一个DOS黑色窗口的问题
2022-05-22 21:51:51
用 Django 开发一个 Python Web API的方法步骤
2021-05-24 02:36:11
sqlserver 巧妙的自关联运用
2012-07-21 14:55:12
Python request中文乱码问题解决方案
2023-11-20 16:16:43
python多重继承新算法C3介绍
2022-05-28 12:27:04
vue弹窗插件实战代码
2024-04-30 08:41:49
![](https://img.aspxhome.com/file/2023/0/133020_0s.png)
Django如何实现内容缓存示例详解
2022-02-23 15:33:01
![](https://img.aspxhome.com/file/2023/8/82518_0s.png)