title: Multiple Categorical values for a single feature how to convert them to binary using python
body: <p>I have a data set of movies which has 28 columns. One of them is genres. For each row in this data set, the value for column genres is of the form "Action|Animation|Comedy|Family|Fantasy".
   I want to encode them using pandas.get_dummies() but since the columns have multiple values, how to deal with such conditions?</p>
  
  <p>I have attached the sample data but with only the relevant columns <a href="https://i.stack.imgur.com/k4lsS.png" rel="nofollow">Data</a>.
  I am expecting an output as <a href="https://i.stack.imgur.com/MYs1U.png" rel="nofollow">Output</a>.</p>
  
  <p>But when I use below code to convert categorical values to binary, </p>
  
  <pre><code>import pandas as pd
  Data = pd.read_csv('sample.csv', encoding = "ISO-8859-1")
  DataConverted = pd.get_dummies(Data)
  DataConverted.to_csv('sample_out.csv')
  </code></pre>
  
  <p>The output is as shown below(I'm not able to post more than two images):</p>
  
  <pre><code>movie_title_Avatar ,movie_title_Pirates of the Caribbean: At World's End ,movie_title_Spectre ,genres_Action|Adventure|Fantasy,genres_Action|Adventure|Fantasy|Sci-Fi,genres_Action|Adventure|Thriller
  1.0,0.0,0.0,0.0,1.0,0.0
  0.0,1.0,0.0,1.0,0.0,0.0
  0.0,0.0,1.0,0.0,0.0,1.0
  </code></pre>