pydata/pandas — pull request #6068 by bburan-galenea (2014-01-24 19:10:46+00:00)
Title: ENH: Keep series name when merging GroupBy result

Important note regarding this pull-request. One test in the GroupBy test suite fails due to this commit (`test_groupby_return_dtype`) because it adds a name to the column index. The "expected" result does not have a name for the column index. I'm not sure what the appropriate course of action is for this.

When using DataFrameGroupBy.apply with a function that returns a
pandas.Series, the list of series are merged into a DataFrame. If the
series are named, this name should be copied over as the name of the
column index in the new DataFrame. This helps facilitate operations
where one may wish to do (as one use-case):

df.GroupBy(key).apply(function_returning_series).stack()

This ensures that when the result is stacked, the new entry in the
MultiIndex column is named after the original series.