I have a $$(418,2)$$ matrix and I want to convert it to csv. so I write:

np.savetxt('titanic1.csv', Sol, fmt='%.2f', delimiter=",",header="PassengerId,Survived")


But the header I get is "# PassengerId" instead of "PassengerId" which is what I want. How can I solve this?

The documentation of numpy says you can add the parameter comments='', but warns that np.loadtxt() might not work on the resulting file.

• Ok, I'll try it tomorrow morning. It's to upload the .csv file to kaggle. By the way I can't give you +1 because I don't have 15 reputation in this forum. Sorry. – elescararriba Jun 24 '19 at 21:38
• No worries, I'm glad I could help. – Louic Jun 25 '19 at 7:45

for row in fileinput.input('titanic1.csv', inplace=True):