0.000003
,当使用熊猫3e-05
在python中读取时,excel单元格中的值将转换为pd.read_excel
。这是我下面的程序。我是python尝试学习的新手。请提出建议。
import pandas as pd
import numpy as np
import os
import glob
os.chdir('C:\\Users\\Desktop\\Files\\')
files = glob.glob("CT.xls")
for f in files:
print(f)
x = pd.read_excel(f).replace(np.nan, '', regex=True)
cols = x.loc[0]
x.drop(x.index[[0]],inplace=True)
x.columns = cols
#-------------------
pipe_del =[]
for i,j in x.iterrows():
st = ''
for k in j:
st = st + (k).strip() + '|'
st = st[0:len(st)-1]
pipe_del.append(st)
newf = f.split('_')[0].split(' ')[0]+'_'+f.split('_')[0].split(' ')[1]+'_'+f.split('_')[0].split(' ')[2]+'_'+f.split('_')[1].split('.')[0]+'.csv'
with open(newf, "w") as output:
for i in pipe_del:
output.write("%s\n" % i)
答案 0 :(得分:3)
尝试
pd.options.display.float_format = '${:,.6f}'.format
并打印结果。
在更改显示设置时要小心,请记住访问文档:https://pandas.pydata.org/pandas-docs/stable/options.html