title: pandas cut: how to convert categorical labels to strings (otherwise cannot export to Excel)?
body: <p>I use pandas.cut() to discretise a continuous variable into a range, and then group by the result.</p>
  
  <p>After a lot of swearing because I couldn't figure out what was wrong, I have learnt that, if I don't supply custom labels to the cut() function, but rely on the default, then the output cannot be exported to excel. If I try this:</p>
  
  <pre><code>import pandas as pd
  import numpy as np    
  
  writer = pd.ExcelWriter('test.xlsx')
  wk = writer.book.add_worksheet('Test')
  
  df= df= pd.DataFrame(np.random.randint(1,10,(10000,5)), columns=['a','b','c','d','e'])
  df['range'] = pd.cut( df['a'],[-np.inf,3,8,np.inf] )
  grouped=df.groupby('range').sum()
  grouped.to_excel(writer, 'Export')
  writer.close()
  </code></pre>
  
  <p>I get:</p>
  
  <pre><code>raise TypeError("Unsupported type %s in write()" % type(token))
  TypeError: Unsupported type &lt;class 'pandas._libs.interval.Interval'&gt; in write()
  which it took me a while to decypher.
  </code></pre>
  
  <p>If instead I do assign labels:</p>
  
  <pre><code>df['range'] = pd.cut( df['a'],[-np.inf,3,8,np.inf], labels =['&lt;3','3-8','&gt;8'] )
  </code></pre>
  
  <p>then it all runs fine.
  Any suggestions on how to handle this without assigning custom labels? In the initial phase of my work I tend not to assign labels, because I still don't know how many bins I want - it's a trial and error approach, and assigning labels at each attempt would be time-consuming.</p>
  
  <p>I am not sure if this can count as a bug, but at the very least it seems like a poorly documented annoyance!</p>