title: Converting a Pandas Dataframe column into one hot labels
body: <p>I have a pandas dataframe similar to this:</p>
  
  <pre><code>  Col1   ABC
  0  XYZ    A
  1  XYZ    B
  2  XYZ    C
  </code></pre>
  
  <p>By using the pandas <code>get_dummies()</code> function on column ABC, I can get this:</p>
  
  <pre><code>  Col1   A   B   C
  0  XYZ   1   0   0
  1  XYZ   0   1   0
  2  XYZ   0   0   1
  </code></pre>
  
  <p>While I need something like this, where the ABC column has a <code>list / array</code> datatype:</p>
  
  <pre><code>  Col1    ABC
  0  XYZ    [1,0,0]
  1  XYZ    [0,1,0]
  2  XYZ    [0,0,1]
  </code></pre>
  
  <p>I tried using the <code>get_dummies</code> function and then combining all the columns into the column which I wanted. I found lot of answers explaining how to combine multiple columns as strings, like this: <a href="https://stackoverflow.com/questions/19377969/combine-two-columns-of-text-in-dataframe-in-pandas-python">Combine two columns of text in dataframe in pandas/python</a>. But I cannot figure out a way to combine them as a list.</p>
  
  <p>This question introduced the idea of using sklearn's <code>OneHotEncoder</code>, but I couldn't get it to work. <a href="https://stackoverflow.com/questions/41185675/how-do-i-one-hot-encode-one-column-of-a-pandas-dataframe">How do I one-hot encode one column of a pandas dataframe?</a></p>
  
  <p>One more thing: All the answers I came across had solutions where the column names had to be manually typed while combining them. Is there a way to use <code>Dataframe.iloc()</code> or splicing mechanism to combine columns into a list?</p>