Python multiple rows to one row
You need to make a dictionary, where the key is the id.  Each value of that is going to be another dictionary of outN to value.
Read a line. You get an id, outN, and a value. Check you have an dict for that id first, and if not, create one. Then shove the value for that outN into the dict for that id.
Second step: You need to collect a list of all the outNs. Make a new set. For each value in your dict, add each of its outN keys to your set. At the end, get a list from the set, and sort it.
Third step: Go through each id in your dict keys, and then each outn in your new sorted list of outns, and print the value of that, with a fallback to zero.   outnval_by_ids[id].get(outn, "0")
There's a weird case here, in that you have a lot of timestamps that you are assuming are duplicate by id. Be careful that is really the case. Assumptions like that cause bugs.
I have a question per below - I need to transform multiple rows of ID into one row, and let the different "output"-values become columns with binary 1/0, like example.
Here is my table!

ID    Output      Timestamp
1     out1        1501
1     out2        1501
1     out5        1501
1     out9        1501
2     out3        1603
2     out4        1603
2     out9        1603

To be transformed into the following:

ID     out1     out2     out3     out4     out5     out9      timestamp
1      1        1        0        0        1        1         1501
2      0        0        1        1        0        1         1603

Can someone help me do this in a flexible way in Python, preferably Pandas? I'm quite new to this, have been using SAS for a good many years so any "transition tips" are greatly appreciated.
Br,