PYTHON报错:Value error:could not convert string to float

TXT文件
TXT文件读取的代码:
txt = np.loadtxt(‘E:\DataSet\CCTSDB\GroundTruth\GroundTruth.txt’)
txtDF = pd.DataFrame(txt)
txtDF.to_csv(‘file1.csv’, index=False)
def csv_data():
csv_data = pd.read_csv(“file1.csv”, names=[“file_num”,“labels”,“style”], index_col=“file_num”)
labels = []
labels = csv_batch_data[list(range(1,4))]
return csv_data
def filename2label(filename, csv_data):
labels = []
for file_name in filename:
file_num = “”.join(list(file_name))
target = csv_data.loc[int(file_num),“label”]
labels.append(target)
return np.array(labels)
Python的报错:Value error:could not convert string to float,跪求大神指点
博客主要记录了Python报错信息,即Value error:could not convert string to float。还给出了TXT文件读取代码,将TXT文件内容读取后转换为DataFrame并保存为CSV文件,同时提供了读取CSV文件及根据文件名获取标签的函数代码。

被折叠的 条评论
为什么被折叠?



