Use {n}. format ()
For ex: '{:n}'.format(1234))
ds_x=[ 0.00000000e+00, 0.00000000e+00, 1.00000000e+00,1.65349200e+05, 1.36897800e+05, 4.71784100e+05]
# For Numpy arrays use '.astype'
# Copy of the array 'ds_x', cast to a specified type 'float'.
# Note: Try type 'float32' OR 'float64' if the below fails to provide correct precision.
data_set = ds_x.astype(float)
for i in data_set:
print("{:.16f}".format(float(i)))
# More about better precision can be found here
Output:
0.0000000000000000
0.0000000000000000
1.0000000000000000
165349.2000000000116415
136897.7999999999883585
471784.0999999999767169
Or you can use the alternative way:
"%.16f" % (float( 00,1.65349200e+05))
The second question regarding PyCharm. You may want to look into formatting markers . Complete details on reformatting .
Update:
Here is a updated code sample with the dataset that was provided by you.
import numpy as np
ds = np.array([[ 0.00000000e+00, 1.00000000e+00, 0.00000000e+00, 2.86637600e+04, 1.27056210e+05, 2.01126820e+05],
[ 0.00000000e+00, 0.00000000e+00, 1.00000000e+00, 1.44372410e+05, 1.18671850e+05, 3.83199620e+05]])
for data_x in iter(ds):
print()
for data_y in data_x:
print("%.16f" % float(data_y))
output:
0.0000000000000000
1.0000000000000000
0.0000000000000000
28663.7599999999983993
127056.2100000000064028
201126.8200000000069849
0.0000000000000000
0.0000000000000000
1.0000000000000000
144372.4100000000034925
118671.8500000000058208
383199.6199999999953434
Regarding the error:
TypeError: only size-1 arrays can be converted to Python scalars
This is because the dataset that you are using is a Python matrix OR a list of a list / two arrays. The first code sample in this post is using one loop which works with one array; however, since you are using a larger dataset containing two arrays on the first loop it will pass the entire array causing the above error to be outputted. To correct this I simply added a second loop to iterate through each value for each array.
.format()method: docs.python.org/3/library/string.html#formatstrings