我收到一个值错误(ValueError:没有足够的值要解压(预期 2,得到1)在file,file2的file,file2行:任何想法如何处理 这个
import pandas as pd
from datetime import timedelta
import glob
directory1= r'L:path'
directory2= r'L:path'
files=glob.glob(directory1 + "\*.xls")
files2=glob.glob(directory2 + "\*.xlsx")
target=pd.read_excel('L:file.xlsx',sheet_name='Sheet1')
target2=pd.read_excel('L:file.xlsx',sheet_name='Sheet1')
for file,file2 in files,files2:
df= pd.read_excel(file,index_col=None, header=0)
df1 = df[:-1]
df2=pd.read_excel(file2,index_col=None, header=0)
df3 = pd.Series(delta.days for delta in (df2['dt1']- df2['Dt2']))
Average=df1['dt'].mean()
Median=df1['dt'].median()
val=20
Average_Var=df3.mean()
Median_Var=df3.median()
val1=10
date=target.iloc[-1]
date=target2.iloc[-1]
df05= date['week']+timedelta(days=7)
df06=date['week']+timedelta(days=7)
sa=pd.Series([df05,Average,Median,val],index=['week','Average Handling
Time','Median Handling Time','Target'])
sas=pd.Series([df06,Average_Var,Median_Var,val1],index=['Week','Average
Handling Time','Median Handling Time','Target'])
df20=target.append(sa,ignore_index=True,verify_integrity=True)
df30=target2.append(sas,ignore_index=True,verify_integrity=True)
writer=pd.ExcelWriter('L:path\file.xlsx',engine='xlsxwriter')
writer1=pd.ExcelWriter('L:path\file.xlsx',engine='xlsxwriter')
df20.to_excel(writer,sheet_name='Sheet1',index=False)
df30.to_excel(writer1,sheet_name='Sheet1',index=False)
writer.save()
writer1.save()
答案 0 :(得分:0)
您可能想要...
for file,file2 in zip(files,files2):
…而不是…
for file,file2 in files,files2: