I would like to write a csv file in Python 3 with the following format: "index, 0". E.g.:
0, 0
1, 0
2, 0
3, 0
...
I have written the following:
csv_file_object = csv.writer(open('file.csv', 'w', newline=''))
Y=np.zeros(2508, dtype=int)
for index, y_aux in enumerate(Y):
csv_file_object.writerow([index, y_aux])
However, when I have opened the csv file, I can see:
0
1
2
3
...
How can I solve this? Thank you.
csv_file_object.writerow([index, str(y_aux)])solve your problem?np.ndarrayto a file, adding an index? To put it another way, isnumpyan essential element of the solution?