pandas 读取excel或生成excel消除科学计数显示

时间:2024-03-09 08:44:54

在我们处理excel表时,通过pandas读取的字段往往会以科学计数的形式显示,有时会对我们做后续的操作有一定影响,那么怎么消除显示呢 ↓

读取excel
pd.read_excel(\'*.xlsx\',converters={\'字段名1\':str,\'字段名2\':str})
这样读取的时候字段就显示全了

生成excel
data.字段.astype(str)
data.to_excel(\'*.xlsx\')
网上还有通过pd.set_option(\'display.float_format\',lambda x : \'%.2f\' % x) # 禁用科学计数法

np.set_printoptions(suppress=True)
大家也可以试试~