title: How do I write a python pandas.DataFrame to a file using aligned space chacarcters?
body: <p>I want to store a pandas.DataFrame to a text file that has the columns aligned using whitespace characters.  If this is my sample DataFrame:</p>
  
  <pre><code>In [1]: import numpy as np
  In [2]: import pandas as pd
  In [3]: df = pd.DataFrame(np.linspace(0,1,9).reshape(3,3))
  In [4]: df
  Out[4]: 
         0      1      2
  0  0.000  0.125  0.250
  1  0.375  0.500  0.625
  2  0.750  0.875  1.000
  [3 rows x 3 columns]
  </code></pre>
  
  <p>I want to do something like this:    </p>
  
  <pre><code>In [5]: df.to_csv('test.txt', sep='?')
  </code></pre>
  
  <p>to get this:</p>
  
  <pre><code>In [6]: more test.txt
    0     1     2
  0 0.0   0.125 0.25
  1 0.375 0.5   0.625
  2 0.75  0.875 1.0
  </code></pre>
  
  <p>What separator should I use?  I want to know if there is a way to do this without using the <code>\t</code> character.  It looks nice </p>
  
  <pre><code>    0       1       2
  0   0.0     0.125   0.25
  1   0.375   0.5     0.625
  2   0.75    0.875   1.0
  </code></pre>
  
  <p>but then my text files have tab characters which create other problems.</p>
  
  <p>If I use <code>sep=' '</code> I get this which is obviously wrong.</p>
  
  <pre><code> 0 1 2
  0 0.0 0.125 0.25
  1 0.375 0.5 0.625
  2 0.75 0.875 1.0
  </code></pre>
  
  <p>I know pandas can read in files like this so I figure there is a way to write out files like this.</p>