[英]How to format excel cells using pandas?
Can you "format cell" using pandas? 您可以使用熊猫“格式化细胞”吗?
I have a column that has large numbers so excel auto the numbers as exponents. 我有一列有很大的数字,所以excel自动将数字作为指数。 I want it so the decimal place will be "0" for the column so I can have a whole number.
我想要它,所以该列的小数位将为“ 0”,因此我可以有一个整数。
Ex. 例如 On excel
在Excel上
A
27782239216
3.93479E+11<---
97336460903
6.40211E+12<---
5.58299E+12<---
I want to set the decimal place in column A to be 0 我想将A列中的小数位设置为0
Ex. 例如 On excel
在Excel上
A
27782239216
393479119893<---
97336460903
6402108304702<---
5582993267823<---
Is there a add format
function for pandas I can use? 我可以为熊猫使用
add format
功能吗?
use below numpy code if there arre integers only: 如果仅存在整数,请使用以下numpy代码:
import numpy as np
dataFrame['ColumnName'] = dataFrame['ColumnName'].astype(np.int64)
you could change display format like below 您可以更改显示格式,如下所示
pd.options.display.float_format = '{:20,.2f}'.format
or 要么
df['A'].apply(lambda x: '%.1f' % x)
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.