I have a numpy array.
values = np.array([14, 21, 13, 56, 12])
I want to write values in one column of a CSV file, the row indices in another column, and a header. I found this function:
numpy.savetxt("foo.csv", values, header="Id,Values", delimiter=",")
I'm not sure how to add the indices (1, 2, 3, 4, 5). Also, my header turns out to be # Id,Values. I'm not sure where the # came from. This is what I get:
# Id,Values
14
21
13
56
12
I want something like this:
Id,Values
1,14
2,21
3,13
4,56
5,12