title: exporting 3D array to Excel workbook
body: <p>I have a 3D array (TAU) with the shape (t,l,b)=(122,40,30) that I want to export to an Excel workbook as 2D with the third dimension being the number of sheets.  So basically the result would be 30 sheets, each with a table of 122 rows and 40 columns. It takes three <code>for</code> loops (t,l and b) to form this array and at the end I take the final result and try to export it into an Excel workbook.<br>
  I am new to Python and it seems i have a problem with the syntax.  I am using pandas. 
  Here is the part of the code that seems to be causing an error. Please note that TAU was created as </p>
  
  <pre><code>TAU=np.zeros(len(t),40,30)
  
  writer = pd.ExcelWriter((stn + '_AOD.xlsx'), engine='xlsxwriter')
  Time = pd.DataFrame(t)
  
  for i in range(0, 40):
      TAU = pd.DataFrame(nc.variables['TAU'][:,i,:])
      Time.to_excel(writer, index=False, header=['DateTime'], sheet_name='bin%d' % i)
      TAU.to_excel(writer, index=False,header=[1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30], sheet_name='bin%d' % i, startcol=1)
  
   writer.save()
  
   np.close()
  </code></pre>
  
  <blockquote>
    <p>error:
        TAU = pd.DataFrame(nc.variables['TAU'][:,i,:])</p>
    
    <p>KeyError: 'TAU'</p>
  </blockquote>
  
  <pre><code>Exception ignored in: &lt;bound method Workbook.__del__ of
  &lt;xlsxwriter.workbook.Workbook object at 0x0000000007D3EFD0&gt;&gt; Traceback
  (most recent call last):   File
  "C:\ProgramData\Anaconda3\lib\site-packages\xlsxwriter\workbook.py",
  line 149, in __del__ Exception: Exception caught in workbook
  destructor. Explicit close() may be required for workbook.
  </code></pre>