用大熊猫解析时避免Excel的科学记数舍入

rha*_*ett 7 python parsing import-from-excel pandas

我有一个excel文件自动生成偶尔非常大的数字,如135061808695.在excel文件中,当您单击单元格时,它会显示完整的数字,135061808695但在视觉上使用自动"常规"格式,数字显示为1.35063E+11.

当我ExcelFile在Pandas中使用时,它会以科学记数法1.350618e+11而不是完整的值来提取值135061808695.有没有办法让Pandas在不搞乱excel文件的情况下提取全部价值?

Joh*_*hnE 6

Pandas很可能会提取全部值,但不会在默认输出中显示它:

df = pd.DataFrame({ 'x':[135061808695.] })

df.x
0    1.350618e+11  
Name: x, dtype: float64
Run Code Online (Sandbox Code Playgroud)

标准python格式:

print "%15.0f" % df.x
135061808695
Run Code Online (Sandbox Code Playgroud)

或者在pandas中,转换为整数类型以获取整数格式:

df.x.astype(np.int64)

0    135061808695
Name: x, dtype: int64
Run Code Online (Sandbox Code Playgroud)