title: Pivot specific rows to columns based on certain conditions in pandas
body: <p>This is the dataframe that I working with where there can be multiple customers associated with a certain case ID on different months (case_ID, cust_val,date are PK in this table).</p>
  <pre><code>case_ID| cust_val | date | primary | action | change   |
      1  | xx       | 3/2  |   1     |        | increase |
      1  | xx       | 3/2  |         |    1   | decrease |
      1  | xx       | 3/1  |   1     |        | decrease |
      1  | xx       | 3/1  |         |   1    | decrease |
      1  | yy       | 3/2  |   1     |        | decrease |
      1  | yy       | 3/2  |         |   1    | increase |
      2  | yy       | 3/2  |         |   1    | increase |
      2  | yy       | 3/2  |     1   |        | increase |
  </code></pre>
  <p>I want the output table to look like this , where for each case_ID, cust_val,date, the change associated with the primary and action are in one row :</p>
  <pre><code>case_ID| cust_val | date | primary_change | action_change |
      1  | xx       | 3/2  |   increase     |   decrease    |
      1  | xx       | 3/1  |   decrease     |   decrease    | 
      1  | yy       | 3/2  |   decrease     |   increase    | 
      2  | yy       | 3/2  |   increase     |   increase    | 
  </code></pre>
  <p>I tried this but this is obviosuly wrong and I am not sure how to solve this  :</p>
  <pre><code>df.pivot(index=['case_ID','cust_val','date'], columns=['primary', 'action'], values='change').reset_index()
  </code></pre>
  <p>Any help is appreciated. Thanks in advance.</p>