pydata/pandas — pull request #4144 by hayd (2013-07-06 00:08:11+00:00)
Title: ENH melt uses column name if available

Currently melt allows you to manually specify the val_name and var_name, this changes the default behaviour to grab the column name if one is available.

```
In [1]: df = pd.DataFrame({'a': {0: 1.0676829999999999, 1: -1.3214049999999999, 2: -0.80733299999999997}, 'b': {0: -1.110463, 1: 0.36891499999999999, 2: 0.082979999999999998}, 'c': {0: 0.20866999999999999, 1: -1.055342, 2: -0.87336100000000005}})

In [2]: df.columns.name = 'foo'

In [3]: df
Out[3]:
foo a b c
0 1.067683 -1.110463 0.208670
1 -1.321405 0.368915 -1.055342
2 -0.807333 0.082980 -0.873361

In [4]: pd.melt(df)
Out[4]:
foo value
0 a 1.067683
1 a -1.321405
2 a -0.807333
3 b -1.110463
4 b 0.368915
5 b 0.082980
6 c 0.208670
7 c -1.055342
8 c -0.873361

Also, cleaned up all the tests (and added some more) in test_reshape.