Getting a leading 0 in the beginning while writing a csv file

while I am writing my CSV file using to_csv function I am getting a leading 0, in the beginning, how should I remove it
I am using the above code to write in csv
result=[]
result.append(“label”)
for i in range(x_test.shape[0]):
ans=predict(x_test[i],w,b)
result.append(ans)
df_result = pd.DataFrame(result)
df_result.to_csv(‘out.csv’,index=False)

Hello @Gautam,

result=[]
#result.append(“label”) 
for i in range(x_test.shape[0]):
   ans=predict(x_test[i],w,b)
   result.append(ans)
df_result = pd.DataFrame(result, columns=["label"])
df_result.to_csv(‘out.csv’,index=False)

This is the correct way to give a name to a column in pandas.

Happy Learning :slight_smile:
Thanks