将列表转换为 numpy 数组时出现奇怪的值格式
Strange value formatting when converting lists to numpy array
我在将常规数组(列表中的列表)转换为 numpy.array 时遇到了一些奇怪的事情。所有的值似乎都以一种奇怪的方式标准化了。这是我的常规列表:
print(output)
print(type(output))
result:
[[0, 301227, 0.86, 0.46, -3.55, 0.53, 135.96, 4, 0.49, 0.33, 0.33 ......
<class 'list'>
当我对 print(np.array(output))
执行相同操作时,结果如下:
[[ 0.00000e+00 3.01227e+05 8.60000e-01 4.60000e-01 -3.55000e+00 5.30000e-01.....
<class 'numpy.ndarray'>
我以前从未遇到过这种情况。希望有人能阐明一些
干杯
值保持不变,它只是另一种表示形式,称为 E notation,
数字mEn
分为两部分,e
前后:
m
左边的部分,是乘数
n
右边的部分,是10的乘方
例如
3.01227e+05 = 3.01227 * 10^5 = 301227
您可以使用 set_printoptions
:
抑制对小数字使用 E notation
np.set_printoptions(suppress=True)
来自文档的标记 suppress
:
If True, always print floating point numbers using fixed point notation, in which case numbers equal to zero in the current precision will print as zero. If False, then scientific notation is used when absolute value of the smallest number is < 1e-4 or the ratio of the maximum absolute value to the minimum is > 1e3. The default is False.
我在将常规数组(列表中的列表)转换为 numpy.array 时遇到了一些奇怪的事情。所有的值似乎都以一种奇怪的方式标准化了。这是我的常规列表:
print(output)
print(type(output))
result:
[[0, 301227, 0.86, 0.46, -3.55, 0.53, 135.96, 4, 0.49, 0.33, 0.33 ......
<class 'list'>
当我对 print(np.array(output))
执行相同操作时,结果如下:
[[ 0.00000e+00 3.01227e+05 8.60000e-01 4.60000e-01 -3.55000e+00 5.30000e-01.....
<class 'numpy.ndarray'>
我以前从未遇到过这种情况。希望有人能阐明一些 干杯
值保持不变,它只是另一种表示形式,称为 E notation,
数字mEn
分为两部分,e
前后:
m
左边的部分,是乘数n
右边的部分,是10的乘方
例如
3.01227e+05 = 3.01227 * 10^5 = 301227
您可以使用 set_printoptions
:
np.set_printoptions(suppress=True)
来自文档的标记 suppress
:
If True, always print floating point numbers using fixed point notation, in which case numbers equal to zero in the current precision will print as zero. If False, then scientific notation is used when absolute value of the smallest number is < 1e-4 or the ratio of the maximum absolute value to the minimum is > 1e3. The default is False.