I am trying to do a simple pivot on my dataframe, with one column as the index, one column as the columns, and one column as the values. Here is a screenshot of the code and the result: 
As you can see, it is just one simple line of code. You can also notice that once the table is pivoted, the columns get placed into alphabetical order, which is not acceptable for the purposes of this program.
This is supposed to be a general program for many use cases, so I can't reindex it by the column names like some other posts have suggested. Depending on the use case, it may have anywhere from 400 to 500 columns (later in the script these get put into smaller dataframes), but this one only has 32.
How can I fix this to keep the original sorting of the columns when I pivot without using the specific column names? I want to keep it general so it will work for most use cases.