title: Create new columns in pandas to store separate values
body: <pre><code>ID    onevalue  twovalue 
  ABC   0.568      0.004
  ABC   5.620     -2.514
  ABC   -1.551    -0.452
  LMN   14.56      7.456  
  LMN   6.750      2.896         
  LMN   5.620      1.166                   
  LMN   8.640      3.486   
  </code></pre>
  <p>Based on the dataframe above, i have the following function:</p>
  <pre><code>cond = (df.onevalue &gt; df.twovalue)
  df['S'] = np.where(cond, df.onevalue,&quot;&quot;)
  </code></pre>
  <p>This works fine and gives me the appropriate 'onevalue' on a new 'S' dataframe/series.</p>
  <p>What I am now trying to do is I want it to create multiple 'S' columns and put just single 'onevalue' variable per column for the given &quot;ID&quot;. The column generation should restart after a new ID appears and that the repeated values should not count. Here's an intended result for clarification's sake:</p>
  <pre><code>ID    onevalue  twovalue    S      S1     S2
  ABC   0.568      0.004    0.568
  ABC   5.620     -2.514          5.620 
  ABC   -1.551    -0.452
  LMN   14.56      7.456    14.56
  LMN   6.750      2.896          6.750
  LMN   5.620      1.166                   
  LMN   8.640      3.486                  8.640
  </code></pre>
  <p>Not sure if pandas allow undefined creation of columns, if that is the case we can assume a maximum of 7 columns per ID.</p>
  <p>I have been trying to work my way around it but no luck. Little help will be appreciated.</p>
  <p>THANKS!</p>