title: How to reshape a table having multiple records for the same id into a table with one record per id without losing information?
body: <p>Basically, I want to transform <a href="https://i.stack.imgur.com/QwcvO.png" rel="nofollow noreferrer">this(Initial)</a> into <a href="https://i.stack.imgur.com/8IXfs.png" rel="nofollow noreferrer">this(Final)</a>. In other words, I want to</p>
  
  <ul>
  <li><p>"squash" the initial table so that it will have only one record per id</p></li>
  <li><p>"dilate" the initial table so that I won't lose any information: create a different column for every possible combination of source and column from the initial table (create c1_A, c1_B, ...). </p></li>
  </ul>
  
  <p>I can work with the initial table as a csv in Python (maybe Pandas) and manually hardcode the mapping between the <a href="https://i.stack.imgur.com/QwcvO.png" rel="nofollow noreferrer">Initial</a> and the <a href="https://i.stack.imgur.com/8IXfs.png" rel="nofollow noreferrer">Final</a> table. However, I don't find this solution elegant at all and I'm much more interested in a sql / sas solution. Is there any way of doing that? </p>
  
  <p>Edit: I what to change </p>
  
  <pre><code>+----+--------+------+-----+------+
  | ID | source |  c1  | c2  |  c3  |
  +----+--------+------+-----+------+
  |  1 | A      |  432 |  56 |    1 |
  |  1 | B      |   53 |   3 |   73 |
  |  1 | C      |    7 | 342 |   83 |
  |  1 | D      |  543 |  43 |   73 |
  |  2 | A      |    8 | 882 |   39 |
  |  2 | B      |    5 |  54 |   46 |
  |  2 | C      |    8 |   3 | 2226 |
  |  2 | D      |   87 |   2 |   45 |
  |  3 | A      |   93 | 143 |   45 |
  |  3 | B      | 1023 |  72 |    8 |
  |  3 | C      |    3 |   3 |  704 |
  |  4 | A      |    2 |   5 |    0 |
  |  4 | B      |   78 | 888 |    2 |
  |  4 | C      |   87 |  23 |   34 |
  |  4 | D      |  112 |   7 |  712 |
  +----+--------+------+-----+------+
  </code></pre>
  
  <p>into </p>
  
  <pre><code>+----+------+------+------+------+------+------+------+------+------+------+------+------+
  | ID | c1_A | c1_B | c1_C | c1_D | c2_A | c2_B | c2_C | c2_D | c3_A | c3_B | c3_C | c3_D |
  +----+------+------+------+------+------+------+------+------+------+------+------+------+
  |  1 |  432 |   53 |    7 |  543 |   56 |    3 |  342 |   43 |    1 |   73 |   83 |   73 |
  |  2 |    8 |    5 |    8 |   87 |  882 |   54 |    3 |    2 |   39 |   46 | 2226 |   45 |
  |  3 |   93 | 1023 |    3 |      |  143 |   72 |    3 |      |   45 |    8 |  704 |      |
  |  4 |    2 |   78 |   87 |  112 |    5 |  888 |   23 |    7 |    0 |    2 |   34 |  712 |
  +----+------+------+------+------+------+------+------+------+------+------+------+------+
  </code></pre>