title: Putting many python pandas dataframes to one excel worksheet
body: <p>It is quite easy to add many pandas dataframes into excel work book as long as it is different worksheets. But, it is somewhat tricky to get many dataframes into one worksheet if you want to use pandas built-in df.to_excel functionality. </p>
  
  <pre><code># Creating Excel Writer Object from Pandas  
  writer = pd.ExcelWriter('test.xlsx',engine='xlsxwriter')   
  workbook=writer.book
  worksheet=workbook.add_worksheet('Validation') 
  df.to_excel(writer,sheet_name='Validation',startrow=0 , startcol=0)   
  another_df.to_excel(writer,sheet_name='Validation',startrow=20, startcol=0) 
  </code></pre>
  
  <p>The above code won't work. You will get the error of </p>
  
  <pre><code> Sheetname 'Validation', with case ignored, is already in use.
  </code></pre>
  
  <p>Now, I have experimented enough that I found a way to make it work. </p>
  
  <pre><code>writer = pd.ExcelWriter('test.xlsx',engine='xlsxwriter')   # Creating Excel Writer Object from Pandas  
  workbook=writer.book
  df.to_excel(writer,sheet_name='Validation',startrow=0 , startcol=0)   
  another_df.to_excel(writer,sheet_name='Validation',startrow=20, startcol=0) 
  </code></pre>
  
  <p>This will work. So, my purpose of posting this question on stackoverflow is twofold. Firstly, I hope this will help someone if he/she is trying to put many dataframes into a single work sheet at excel. </p>
  
  <p>Secondly,  Can someone help me understand the difference between those two blocks of code? It appears to me that they are pretty much the same except the first block of code created worksheet called "Validation" in advance while the second does not. I get that part. </p>
  
  <p>What I don't understand is why should it be any different ? Even if I don't create the worksheet in advance, this line, the line right before the last one, </p>
  
  <pre><code> df.to_excel(writer,sheet_name='Validation',startrow=0 , startcol=0)  
  </code></pre>
  
  <p>will create a worksheet anyway. Consequently, by the time we reached the last line of code the worksheet "Validation" is already created as well in the second block of code.  So, my question basically, why should the second block of code  work while the first doesn't?  </p>
  
  <p>Please also share if there is another way to put many dataframes into excel using the built-in df.to_excel functionality !! </p>