title: How to combine generating multiple variables in one class
body: <p>I have a dataset as below</p>
  
  <pre><code>import pandas as pd
  import sklearn
  df= pd.DataFrame({'color': ['red', 'red,blue','red,blue,yellow', 'red,yellow', 'blue,yellow']})
  </code></pre>
  
  <p>I get a new variable like this</p>
  
  <pre><code>df['red'] = 0
  df.ix[df['color'].str.contains("red") == True, 'red'  ] =1
  </code></pre>
  
  <p>similarly I can get <code>df['blue'] &amp; df['yellow']</code>
  Then i had to use it in <code>class</code> (i want to apply <code>pipeline</code>)</p>
  
  <pre><code>class Red():
  
  def transform(self, X, y=None, **fit_params):
      X['red'] = 0
      X.loc[X['color'].str.contains("red") == True, 'red'  ] = 1
      return X['red'].values.reshape(len(X),1)
  
  def fit_transform(self, X, y=None, **fit_params):
      self.fit(X, y, **fit_params)
      return self.transform(X)
  
  def fit(self, X, y=None, **fit_params):
      return self
  </code></pre>
  
  <p>It works but I want to get <code>class</code> which generates also <code>'blue' &amp; 'yellow'</code>. Make classes for every 'color'? In the real dataset there are a few dozens 'colors'.
  I'm new in class, please give any idea how to combine in one <code>class</code> generating multiple variables</p>