Reshaping a pandas DataFrame into stacked/record/database/long format
问题 What is the best way to convert a pandas DataFrame from wide format into stacked/record/database/long format? Here's a small code example: Wide format: date hour1 hour2 hour3 hour4 2012-12-31 9.18 -0.10 -7.00 -64.92 2012-12-30 13.91 0.09 -0.96 0.08 2012-12-29 12.97 11.82 11.65 10.20 2012-12-28 22.01 16.04 15.68 11.67 2012-12-27 11.44 0.07 -19.97 -67.98 ... Stacked/record/database/long format (needed): date hour price 2012-12-31 00:00:00 hour1 9.18 2012-12-31 00:00:00 hour2 -0.1 2012-12-31 00