加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 编程开发 > Python > 正文

python – 熊猫数据精度

发布时间:2020-12-20 13:02:41 所属栏目:Python 来源:网络整理
导读:参见英文答案 How to round values only for display in pandas while retaining original ones in the dataframe?????????????????????????????????????1个 默认情况下,数据框中的数值仅存储6位小数.我如何获得完整的精度. eg 34.98774564765 is stored as
参见英文答案 > How to round values only for display in pandas while retaining original ones in the dataframe?????????????????????????????????????1个
默认情况下,数据框中的数值仅存储6位小数.我如何获得完整的精度.

eg 34.98774564765 is stored as 34.987746. I do want the full value. 
eg2 0.00000565  is stored as 0. .
apart from applying formats to each data frame is there any global setting that helps preserving the precision.

谢谢

解决方法

不,34.98774564765默认只打印六位小数:

>>> pandas.DataFrame([34.98774564765])
           0
0  34.987746

数据本身具有更高的精度:

>>> pandas.DataFrame([34.98774564765])[0].data[0]
34.98774564765

您可以通过更改pandas.options.display.precision来更改用于打印帧的默认值.

例如:

>>> pandas.set_option("display.precision",8)
>>> pandas.DataFrame([34.98774564765])
                0
0  34.98774564765

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读