title: How to binarize the values in a pandas DataFrame?
body: <p>I have the following DataFrame:</p>
  
  <pre><code>df = pd.DataFrame(['Male','Female', 'Female', 'Unknown', 'Male'], columns = ['Gender'])
  </code></pre>
  
  <p>I want to convert this to a DataFrame with columns 'Male','Female' and 'Unknown' the values 0 and 1 indicated the Gender. </p>
  
  <pre><code>Gender  Male  Female
  Male     1      0
  Female   0      1
         .
         .
         .
         .
  </code></pre>
  
  <p>To do this, I wrote a function and called the function using map.</p>
  
  <pre><code>def isValue(x , value):
  if(x == value):
      return 1
  else: 
      return 0
  
  
  for value in df['Gender'].unique():
      df[str(value)] = df['Gender'].map( lambda x: isValue(str(x) , str(value)))
  </code></pre>
  
  <p>Which works perfectly. But is there a better way to do this? Is there an inbuilt function in any of sklearn package that I can use? </p>