title: How can I simplify my pandas script using a loop?
body: <p>I have the following code:</p>
  <pre><code>import pandas as pd
  
  df22=pd.read_excel(r&quot;C:\Users\H\Desktop\Files\Table22.xlsx&quot;)
  
  #Select the sheets that are to be transformed
  df3=pd.read_excel(r&quot;C:\Users\H\Desktop\Files\Table3.xlsx&quot;)
  df4=pd.read_excel(r&quot;C:\Users\H\Desktop\Files\Table4.xlsx&quot;)
  df5=pd.read_excel(r&quot;C:\Users\H\Desktop\Files\Table5.xlsx&quot;)
  df6=pd.read_excel(r&quot;C:\Users\H\Desktop\Files\Table6.xlsx&quot;)
  df7=pd.read_excel(r&quot;C:\Users\H\Desktop\Files\Table7.xlsx&quot;)
  df8=pd.read_excel(r&quot;C:\Users\H\Desktop\Files\Table8.xlsx&quot;)
  df9=pd.read_excel(r&quot;C:\Users\H\Desktop\Files\Table9.xlsx&quot;)
  df10=pd.read_excel(r&quot;C:\Users\H\Desktop\Files\Table10.xlsx&quot;)
  df11=pd.read_excel(r&quot;C:\Users\H\Desktop\Files\Table11.xlsx&quot;)
  df12=pd.read_excel(r&quot;C:\Users\H\Desktop\Files\Table12.xlsx&quot;)
  df13=pd.read_excel(r&quot;C:\Users\H\Desktop\Files\Table13.xlsx&quot;)
  df14=pd.read_excel(r&quot;C:\Users\H\Desktop\Files\Table14.xlsx&quot;)
  df15=pd.read_excel(r&quot;C:\Users\H\Desktop\Files\Table15.xlsx&quot;)
  df16=pd.read_excel(r&quot;C:\Users\H\Desktop\Files\Table16.xlsx&quot;)
  df17=pd.read_excel(r&quot;C:\Users\H\Desktop\Files\Table17.xlsx&quot;)
  df18=pd.read_excel(r&quot;C:\Users\H\Desktop\Files\Table18.xlsx&quot;)
  df19=pd.read_excel(r&quot;C:\Users\H\Desktop\Files\Table19.xlsx&quot;)
  df20=pd.read_excel(r&quot;C:\Users\H\Desktop\Files\Table20.xlsx&quot;)
  df21=pd.read_excel(r&quot;C:\Users\H\Desktop\Files\Table21.xlsx&quot;)
  
  df=pd.concat([df22,df3,df4,df5,df6,df7,df8,df9,df10,df11,df12,df13,df14,df15,df16,df17,df18,df19,df20,df21], join='inner')
  
  df.to_excel(r'C:\Users\H\Desktop\Files\Allweeks.xlsx', sheet_name='sheet1', index = False) 
  </code></pre>
  <p>It appends Week22.xlsx with all weeks between 3 to 21. I'm trying to find out if anyone knows how this script can be improved. I was trying to use loops but I just couldn't get it to work.</p>