title: optimising way of exporting a dataframe in pandas
body: <p>I want to export dataframes efficiently by avoiding the use of loops.My format is specific so I can not use any prebuilt function like pandas.to_csv...
  This is what i have at the moment</p>
  
  <pre><code>def export(datafr,fout):
      fo=open(fout,'w')
      fo.write('#channel d '+'\" "date" - date\n')
      fo.write('#channel t '+'\" "time" - time\n')                
  
  fo.write("#begindata\n")        
      for date in datafr.df.index:#2011-11-02 00:00:00
  
          record=datafr.df.ix[date]#row
          fo.write(str(date)+" ")
          for i in record:
              fo.write("%3.3f" % (i)+" ")
              fo.write("\n")
      fo.close()
  </code></pre>
  
  <p>It works, but I have to use loops what is not efficient at all with long time series. I thought about using map() or pandas.apply() but I do not get anything so far. One try:</p>
  
  <pre><code>site = DataFrame(np.random.randn(4, 3), columns=list('bde'), index=['Utah', 'Ohio', 'Texas', 'Oregon'])
  fout='c://Site.dat'
  fo=open(fout,'w')
  def writed(f,i,data):
      f.write(str(i)+" ")
      f.write("%3.3f" % (data)+" ")
  map(writed,fo,site.index,site.values)
  </code></pre>
  
  <p>but I get this error</p>
  
  <pre><code>IOError: File not open for reading 
  </code></pre>