当dtype是float16时,Pandas为什么不旋转呢?

2024-09-29 19:27:24 发布

您现在位置:Python中文网/ 问答频道 /正文

为什么熊猫在dypes为np.float16时不舍入数据帧

pd.DataFrame(np.random.rand(10) for x in range(0, 10)).astype(np.float16).round(2)

np.round(pd.DataFrame(np.random.rand(10) for x in range(0, 10)).astype(np.float16), 2)

pd.DataFrame(np.random.rand(10) for x in range(0, 10)).astype(np.float16).round({0:2, 1:2})

这肯定是以前提过的,但我哪儿都找不到


Tags: 数据indataframefornprangerandompd
1条回答
网友
1楼 · 发布于 2024-09-29 19:27:24

四舍五入。高达float16精度的极限,结果完全符合您的要求。但是,float16精度的限制明显低于熊猫在默认情况下尝试打印的6位有效数字,因此您可以看到一些在打印浮点数字时通常隐藏的表示不精确性

相关问题 更多 >

    热门问题