1 回答

TA貢獻(xiàn)1831條經(jīng)驗(yàn) 獲得超9個(gè)贊
我根本沒(méi)有收到錯(cuò)誤。在pd.csv_read(... sep=","). 您還應(yīng)該添加(..., skiprows=1)該函數(shù),以不將文件頭作為第一個(gè)數(shù)據(jù)行讀取。
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]
添加回答
舉報(bào)