博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
TypeError: list indices must be integers or slices, not tuple
阅读量:5099 次
发布时间:2019-06-13

本文共 1391 字,大约阅读时间需要 4 分钟。

由于dataset是一个列表

>>> dataset[[1.658985, 4.285136], [-3.453687, 3.424321], [4.838138, -1.151539], [-5.379713, -3.362104], [0.972564, 2.924086], [-3.567919, 1.531611], [0.450614, -3.302219], [-3.487105, -1.724432], [2.668759, 1.594842], [-3.156485, 3.191137], [3.165506, -3.999838], [-2.786837, -3.099354], [4.208187, 2.984927], [-2.123337, 2.943366], [0.704199, -0.479481], [-0.39237, -3.963704], [2.831667, 1.574018], [-0.790153, 3.343144], [2.943496, -3.357075], [-3.195883, -2.283926], [2.336445, 2.875106], [-1.786345, 2.554248], [2.190101, -1.90602], [-3.403367, -2.778288], [1.778124, 3.880832], [-1.688346, 2.230267], [2.592976, -2.054368], [-4.007257, -3.207066], [2.257734, 3.387564], [-2.679011, 0.785119], [0.939512, -4.023563], [-3.674424, -2.261084], [2.046259, 2.735279], [-3.18947, 1.780269], [4.372646, -0.822248], [-2.579316, -3.497576], [1.889034, 5.1904], [-0.798747, 2
所以获取第一列的时候就会出现这个问题

>>> dataset[:,0]Traceback (most recent call last):  File "
", line 1, in
TypeError: list indices must be integers or slices, not tuple
需要将之转为矩阵

>>> dataset=mat(dataset)>>> dataset[:,0]matrix([[ 1.658985],        [-3.453687],        [ 4.838138],        [-5.379713],        [ 0.972564],        [-3.567919],        [ 0.450614],        [-3.487105],        [ 2.668759],        [-3.156485],        [ 3.165506],

转载于:https://www.cnblogs.com/flyingcr/p/10326976.html

你可能感兴趣的文章
如何在g++中添加include文件的目录
查看>>
BlockingQueue深入解析
查看>>
网络编程
查看>>
POJ -2236 Wireless Network
查看>>
CentOS6.9安装Filebeat监控Nginx的访问日志发送到Kafka
查看>>
无向图求桥 UVA 796
查看>>
Nginx+Keepalived 实现双击热备及负载均衡
查看>>
五分钟搭建WordPress博客(二)
查看>>
Vue_(组件通讯)子组件向父组件传值
查看>>
jvm参数
查看>>
确认是否是因为做了物理I/O而导致的性能不佳
查看>>
Something-Summary
查看>>
Spring学习笔记
查看>>
6个有用的MySQL语句
查看>>
JMeter-生成性能测试结果报告
查看>>
linux c/c++ IP字符串转换成可比较大小的数字
查看>>
我对前端MVC的理解
查看>>
sql: table,view,function, procedure created MS_Description in sql server
查看>>
[网络流24题] 最长k可重区间集问题 (费用流)
查看>>
路径依赖理论
查看>>