简体   繁体   English

使用 float64 的熊猫最大小数位数

[英]pandas maximum number of decimal places using float64

I have a code where i read a data set as strings and what to convert it to float.我有一个代码,我将数据集读取为字符串以及将其转换为浮点数的内容。 As a string the values are something like this (The unit is Angstrom):作为字符串,值是这样的(单位是埃):

-11.22221784

when i now covert it via:当我现在通过以下方式隐藏它时:

cols=[....a list of columns i want to convert]

for col in cols:
    df[col] = df[col].astype(float)

the value will become rounded to:该值将四舍五入为:

-11.222218

which i do not want!!我不想要的!! if i convert it via如果我通过

....
import decimal as D

for col in cols:
    df[col] = df[col].astype(D.Decimal)

i get the correct value in my dataframe but i can not plot the data as the dtype panas sees is object.我在我的数据框中得到了正确的值,但我无法绘制数据,因为 dtype panas 看到的是对象。

Pandas is rendering the column with 6 decimal places, it's storing it correctly: Pandas 使用 6 个小数位呈现列,它正确存储它:

In [11]: pd.Series([-11.22221784])
Out[11]:
0   -11.222218
dtype: float64

In [12]: pd.Series([-11.22221784])[0]
Out[12]: -11.22221784

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM