python - numpy savetxt formated as integer is not saving zeroes -


i trying save numpy.array .csv in following way.

with open("resulttr.csv", "wb") f:     f.write(b'imageid,label\n')     numpy.savetxt(f, result, fmt='%i', delimiter=",") 

result numpy.array consists of 2 columns, first column indices (numbers 1 through n) , second column values (0,9).

unfortunately have problem whenever there 0 in second column nothing written resulting .csv file in second column.

in other words first 5 rows of array looks this:

[[  1.00000000e+00   2.00000000e+00]  [  2.00000000e+00   0.00000000e+00]  [  3.00000000e+00   9.00000000e+00]  [  4.00000000e+00   9.00000000e+00]  [  5.00000000e+00   3.00000000e+00] 

and first 5 rows of .csv file this:

imageid,label 1,2 2 3,9 4,9 5,3 

it looks me code should work , not saving zeroes seems me weird. have idea can possibly wrong code writing .csv file?

edit:

just compleetnes python version 2.7.2 , it's running on mac os x 10.9.2

thank in advance help.

i try saving array int array, in result.astype(int), or in full:

with open("resulttr.csv", "wb") f:     f.write(b'imageid,label\n')     numpy.savetxt(f, result.astype(int), fmt='%i', delimiter=",") 

Comments

Popular posts from this blog

javascript - Count length of each class -

What design pattern is this code in Javascript? -

hadoop - Restrict secondarynamenode to be installed and run on any other node in the cluster -