title: Saving Pandas dataframe indices to file
body: <p>I am trying to save just the indices of a dataframe to a file. Here is what I've tried:</p>
  
  <p>A)</p>
  
  <pre><code>np.savetxt("file_name", df.index.values)
  </code></pre>
  
  <p>returns:</p>
  
  <pre><code>TypeError: Mismatch between array dtype ('object') and format specifier ('%.18e')
  </code></pre>
  
  <p>B)</p>
  
  <pre><code>df.index.values.tofile("file_name")
  </code></pre>
  
  <p>returns:</p>
  
  <pre><code>IOError: cannot write object arrays to a file in binary mode
  </code></pre>
  
  <p>C) </p>
  
  <pre><code>with open("file_name","w") as f:
      f.write("\n".join(df_1_indexes.values.tolist()))
  </code></pre>
  
  <p>Can someone please explain why A) and B) failed? I'm at a loss. </p>
  
  <p>Cheers</p>