I have the following source code:
npW_x = np.array(my_np_array)
npW_round_111 = np.around(npW_x, decimals=0)
sum_x_111 = np.sum(npW_round_111, axis=1)
np.savetxt("file1.txt", sum_x_111)
File output
3.200000000000000000e+01
5.500000000000000000e+01
3.300000000000000000e+01
4.900000000000000000e+01
5.200000000000000000e+01
5.500000000000000000e+01
3.800000000000000000e+01
5.200000000000000000e+01
5.100000000000000000e+01
3.100000000000000000e+01
3.100000000000000000e+01
3.200000000000000000e+01
5.100000000000000000e+01
... ... ... ... ... ...
The expected output is as follows:
3
6
3
5
5
6
4
5
5
3
3
3
5
... ... ... ... ... ...
How can I do this?
dtypeof your choice -np.sum(npW_round_111, axis=1,dtype=np.int64)3.200000000000000000e+01is 32.0, not 3.0. Thee+01means "times 10 to the 1st power".numpy.savetxtdefaults tofmt='%.18e'even if you pass it an array of integer dtype.