python - 写入 CSV 给出,错误:无法将字符串转换为浮点数
问题描述
我在将 CSV 文件添加到 Python 时遇到问题,我编写了这个程序:
import csv
file=r'C:Users\kloner\Desktop\Stage\partactions.csv'
reader=csv.reader(open(file, encoding = "ISO-8859-1"))
liste=[]
for row in reader:
liste.append(row)
liste.pop(0)
M=matrix(RDF,liste)
print(M)
但它给了我以下错误:
错误:无法将字符串转换为浮点数
解决方案
我认为矩阵是 np.matrix 并且有些代码很奇怪。
也许它应该是这样的。
import csv
from numpy import matrix
file=r'C:Users\kloner\Desktop\Stage\partactions.csv'
reader=csv.reader(open(file, encoding = "ISO-8859-1"))
liste=[]
for row in reader:
liste.append(row)
liste.pop(0)
M=matrix(liste)
print(M)
推荐阅读
- reactjs - 在事件发生之前执行动作
- python - Nginx:Linux 服务器上的内部端口转发
- sql - 如何优化结合了 INNER JOIN、DISTINCT 和 WHERE 的 SQL 查询?
- python - 为什么整数可以存储十六进制值但不能存储相同的十进制值?
- r - 如何使用 R 从 ECMWF 数据存档中下载 ERA-Interim 数据?
- php - 通过 PHP MYSQL 创建循环 JSON 不使用不同的查询
- javascript - 如何强制更改选项
- hdfs - NiFi moveHDFS 处理器似乎什么都不做
- android - 将图像从 url 加载到 recyclerview,无需 3rd 方库
- reactjs - react-router 将 const 转换为带有子路由的类