title: Pandas: trouble with to_excel using a grouped dataframe
body: <p>I am trying to save a dataframe I created using groupby into an excel file, with the to_excel function. When I preview the data in ipython notebook, it appears as desired. The groupby code is simple:</p>
  
  <pre><code>    grouped = teach_freq.groupby(['Focal','follow','Activity'])
      grouped.head()
  
      &lt;class 'pandas.core.frame.DataFrame'&gt;
      MultiIndex: 1797 entries, (10107.0, 192.0, ff, 25220.0) to (53704.0, 142.0, ss.rn, 18823.0)
      Data columns (total 16 columns):
      Epoch         1790  non-null values
      follow        1797  non-null values
      T_Opp         1797  non-null values
      T_Dir         1797  non-null values
      T_Enh         1797  non-null values
      T_SocTol      1797  non-null values
  </code></pre>
  
  <p>... and so on
          dtypes: float64(3), int64(6), object(7)</p>
  
  <p>The to_excel code is also simple:</p>
  
  <pre><code>    grouped.to_excel('filename.xls', sheet_name='sheet1')
  </code></pre>
  
  <p>When I run this last code, only a few lines of data make it to the excel file (about 3 out of nearly 1800 lines of data. I get a preview of a different portion of the data in ipython notebook that looks like this: </p>
  
  <pre><code>   Focal  follow  Activity     
     10107  192     ff               None
     10212  187     rn.ss            None
     194            hc               None
                    pa               None
     10213  166     hr.hg            None
                    pa               None
                    sr.hg            None
                    sr.hl            None
  </code></pre>
  
  <p>These data appear to be only the 3 columns I've grouped by, plus a column of None, which doesn't exist in my dataframe. In the file, I get 6 lines of correctly formatted data, headings and all. If I keep an eye on the file that's being written to in Finder, the size varies up and down as the to_excel line of code, which I think suggests that it is writing small chunks of data to the file at a time, but over-writing each one with the next. </p>
  
  <p>The final file size is tiny (6KB) but at some points while the code is running, it is larger (up to 32KB). </p>
  
  <p>Finally, the last few lines of data that are displayed in the ipython data appear to be the lines just before those that are successfully written to the excel file, which suggests that for some reason it's only saving those lines of data that are past the ipython notebook preview limit. I'm not sure why anyone would want that as a feature, or why it would function this way.</p>
  
  <p>This is bizarre, I'm hoping someone can explain to me why this is happening. I've looked at the groupby and to_excel documentation and browsed for anyone with a similar problem, but haven't found it. I've used to_excel for dataframes with this same data, that are not grouped, and haven't had any similar problems. I actually am not even clear on why I'm getting output within the notebook, as the other times I have used to_excel, I only see output in the excel file itself.</p>