Python Forum
rounding - Printable Version

+- Python Forum (https://python-forum.io)
+-- Forum: Python Coding (https://python-forum.io/forum-7.html)
+--- Forum: Data Science (https://python-forum.io/forum-44.html)
+--- Thread: rounding (/thread-8942.html)



rounding - Stevger - Mar-13-2018

Hello,
can somebody help me with following code:

import scipy.misc
img_array = scipy.misc.imread("Test_Set/TestSet_03/2828_my_own_4.png", flatten=True)
img_data = 255.0 - img_array.reshape(784)
img_data = (img_data / 255.0 * 0.99) + 0.01
img_data = ','.join(map(str, img_data))

print (img_data)
The problem is the following: img_data consists of a list of numbers

eg: 0.23905884 0.15364707 etc...
after separating those numbers by a comma by the command "img_data = ','.join(map(str, img_data))"
I have 0.239059,0.153647,etc...

So my numbers are rounded. But what I want to have after the comma separating is
0.23905884,0.15364707

Anybody knows how to adapt my code so I have the expected result?

Thanks a lot