title: What is the fastest way to serialize a DataFrame besides to_pickle?
body: <p>I need to serialize DataFrames and send them over the wire.  For security reasons, I cannot use pickle.</p>
  
  <p>What would be the next fastest way to do this?  I was intrigued by msgpacks in v0.13, but unless I'm doing something wrong, the performance seems much worse than with pickle.</p>
  
  <pre><code>In [107]: from pandas.io.packers import pack
  
  In [108]: df = pd.DataFrame(np.random.rand(1000, 100))
  
  In [109]: %timeit buf = pack(df)
  100 loops, best of 3: 15.5 ms per loop
  
  In [110]: import pickle
  
  In [111]: %timeit buf = pickle.dumps(df)
  1000 loops, best of 3: 241 µs per loop
  </code></pre>
  
  <p>The best I've found so far is just serializing homogenous numpy arrays (df.as_blocks() was handy) using array.tostring() and rebuilding the DataFrame from them.  The performance is comparable to pickle.</p>
  
  <p>However, with this approach, I am forced to convert columns of dtype=object (i.e., anything with at least a string) to be entirely string since Numpy's fromstring() cannot deserialize dtype=object.  Pickle manages to preserve mixed types in object columns (it seems to be including some function in the pickle output).</p>