title: Python FastText: How to create a corpus from a Dataframe Column
body: <ul>
  <li>I need to create a <strong>corpus</strong> for my Email Classifer .
  Right now am Using <strong>fasttext 0.8.3</strong> but it expects text file as a input whereas 
  i need to pass a dataframe as an input .<br></li>
  <li><p>It shows error while i am Using following Code :- </p>
  
  <p>```</p>
  
  <p>import fasttext   </p>
  
  <pre><code>x_val = df['Message']  
  y_val = df['Categories']  
  model = fasttext.skipgram(x_val, y_val)  
  print model.words
  
  TypeError:
  &lt;ipython-input-105-58241a9688b5&gt; 
   &lt;module&gt;() 
  ----&gt; 1 model = fasttext.skipgram(x_val, y_val) 
        2 print model.words # list of words in dictionary 
        fasttext/fasttext.pyx in fasttext.fasttext.skipgram (fasttext/fasttext.cpp:6451)() 
        fasttext/fasttext.pyx in fasttext.fasttext.train_wrapper (fasttext/fasttext.cpp:5223)() 
       /root/anaconda2/lib/python2.7/genericpath.pyc in isfile(path) 
             35 """Test whether a path is a regular file""" 
             36 try: 
        ---&gt; 37 st = os.stat(path) 
             38 except os.error: 
             39 return False 
       TypeError: coercing to Unicode: need string or buffer, Series found
  
  ```
  </code></pre>
  
  <ul>
  <li>In above code the <em>df['Message'] and df['Categories']</em> are the dataframe column in which it contains mails and the category respectively .</li>
  <li>There are 30123 mails in the dataframe .</li>
  <li>I already go through the Documentation of fasttext but i dont find someting useful.<br></li>
  </ul>
  
  <p><a href="https://pypi.python.org/pypi/fasttext" rel="nofollow noreferrer">Fasttext Tutorial refrence</a></p>
  
  <p>Thanks for the Help.</p></li>
  </ul>