【发布时间】:2019-08-14 15:48:59
【问题描述】:
我需要在现有的 CSV 文件中添加一列。所以我正在打开文件,将列连接到它并尝试将其保存回来。但我得到错误:
TypeError: Mismatch between array dtype ('object') and format specifier ('%.18e %.18e %.18e')
我使用的代码是:
dataframe = pandas.read_csv(file)
dataset = dataframe.values
labels_col=numpy.zeros((len(dataset),1))
dataset=numpy.concatenate([dataset,labels_col],axis=1)
numpy.savetxt(file.strip('.csv')+'labelled.csv',dataset)
【问题讨论】:
标签: python numpy concatenation