我有一个包含100000个元素的大型数组,值的样本如下:
array([[ 1.96713769e-01, 5.76482242e-01, 2.26803989e-01,
7.84528623e-01, 8.38717696e-02, 1.31599608e-01,
3.49645544e-03, 9.89583476e-01, 6.92006905e-03,
8.97708472e-08, 9.99999731e-01, 1.79541646e-07,
1.96615857e-18, 1.00000000e+00, 0.00000000e+00],
[ 1.74043502e-01, 6.12687828e-01, 2.13268670e-01,
8.20000770e-01, 6.81814868e-02, 1.11817743e-01,
4.36557418e-03, 9.87016637e-01, 8.61778870e-03,
1.30950035e-07, 9.99999607e-01, 2.61899967e-07,
3.58177845e-18, 1.00000000e+00, 0.00000000e+00]])
如何将值四舍五入为4f
答案 0 :(得分:0)
你喜欢这个解决方案吗?
[ round(n,4) for n in arr for arr in a]
或类似的东西看到结果
list([ list(round(n,4)) for n in arr for arr in a])
圆形你可以使用你喜欢的任何文件夹