如何摆脱行号,to_csv?

How to get rid of the row numbers, to_csv?

在预测分类问题的目标值后尝试获取 .csv 文件中的预测值以及特定数据实例的 ID,但获取了不必要的行号。

x_train,x_test,y_train,y_test = train_test_split(x,y, random_state=101,strtify =y)

cls = DecisionTreeClassifier()
cls.fit(x_train,y_train)

pred = cls.predict(x_test)
prediction = pd.DataFrame({'id':x_test['id'],'target':pred})
prediction.to_csv("path/prediction.csv")

x_test.head() image

to.csv() image

index=False,doc指定这个参数

prediction.to_csv("path/prediction.csv",index=False)