title: Create column with aggregation of previous column - based on condition
body: <p>Dataframe with 3 columns:</p>
  
  <pre><code>FLAG CLASS   STUDENT
  yes 'Sci'   'Francy'
  no  'Sci'   'Alex'
  yes 'math'  'Arthur'
  yes 'math'   NaN
  yes 'eng'   'Jack'
  yes 'math'  'Paul'
  yes 'eng'   'Zach'
  
  </code></pre>
  
  <p>I want to add a new column ALL_STUD with all the students in each class. But, do this only for the rows with FLAG = yes. Result below:</p>
  
  <pre><code>FLAG CLASS   STUDENT   ALL_STUD
  yes 'Sci'   'Francy'  'Francy, Alex'
  no  'Sci'   'Alex'     NaN
  yes 'math'  'Arthur'  'Arthur, Paul'
  yes 'math'   NaN      'Arthur, Paul'
  yes 'eng'   'Jack'    'Jack, Zach'
  yes 'math'  'Paul'    'Arthur, Paul'
  yes 'eng'   'Zach'    'Jack, Zach'
  </code></pre>
  
  <p>I have been trying something like this:</p>
  
  <pre><code>df.loc[df['FLAG']=='yes', 'ALL_STU'] = df.groupby('CLASS').STUDENT.transform(','.join)
  </code></pre>
  
  <p>But the students from the class 'math' cannot be transformed with <code>(','.join)</code> into   <code>'Arthur, Paul'</code> because there's an empty name <code>NaN</code>in the math class. Any solution, or other way to do this?</p>
  
  <p>Continuation from this <a href="https://stackoverflow.com/questions/56050571/pandas-create-a-new-column-with-aggregation-of-previous-column/56050828?noredirect=1">question</a>.</p>