Programmatically reshaping data

July 15th, 2015  |  Published in Uncategorized

Yesterday at work, my coworker needed to reshape a data table, from CSV. The data was a time series, with one row per date. He wanted to reshape the data so there was one row per day of the year with a column for the desired variable for each year. He observed that there were 93 distinct days of the year for each year and used some clever Excel functions and auto-fills to do this in about 5 minutes. I spend considerably more time figuring out how to do this in PostgreSQL, Python and R.