1 回答
TA贡献1831条经验 获得超9个赞
我根本没有收到错误。在pd.csv_read(... sep=","). 您还应该添加(..., skiprows=1)该函数,以不将文件头作为第一个数据行读取。
import pandas as pd
col_names = ['pregnant', 'glucose', 'bp', 'skin', 'insulin', 'bmi', 'pedigree', 'age', 'label']
csv_path = r'D:\MachinLearning\MyDataSets_Implementations\pima-indians-diabetes.csv'
pima = pd.read_csv(csv_path, header=1, names=col_names, sep=",", skiprows=1)
print(pima.head())
给出输出
pregnant glucose bp ... pedigree age label
6 148 72 35 0 33.6 0.627 50 1 1 85 66 ... 0.351 31 0
8 183 64 0 0 23.3 0.672 32 1 1 89 66 ... 0.167 21 0
0 137 40 35 168 43.1 2.288 33 1 5 116 74 ... 0.201 30 0
[3 rows x 9 columns]
添加回答
举报