title: How to split rows in a dataframe based on column value?
body: <p>I am trying to split my rows into multiple rows based on if a value exists in a column. I am able to filter based on the column value but would like to split the row into two based on the condition and return only specific parts of the row. The dataframe consists of different types of payments and the activity field represents the payment type that occurred. I would like for when there is a specific payment type to split the row into two. In the example below, when payment 2 exists I want it to be a separate transaction.</p>
  <p>I have the following dataframe:</p>
  <pre><code>ID      Payment 1      Payment 2      Payment 3    Payment 4    Payment 5      Activity 
  1          10             0              0            0              0         Payment 1  
  2          0              10             15           0              0         Payment 2, Payment 3
  3          10             20             30           0              0         Payment 1, Payment 2, Payment 3
  </code></pre>
  <p>But I would like for the dataframe to be:</p>
  <pre><code>ID      Payment 1      Payment 2      Payment 3    Payment 4    Payment 5       Activity 
   1          10             0              0            0              0         Payment 1  
   2          0              10             0            0              0         Payment 2
   2          0              0              15           0              0         Payment 3
   3          10             0              30           0              0         Payment 1, Payment 3
   3          0              20             0            0              0         Payment 2
  </code></pre>