Should the following work? On revision 07403ca.

weights = np.random.randn(4,4)
panel = pd.util.testing.makePanel(nper=2).to_frame()
panel.groupby(level=0).apply(lambda x : np.dot(weights, x))

I realize I can do

panel.groupby(level=0).apply(lambda x : pd.DataFrame(np.dot(weights, x), index=x.index, columns=x.columns))

Would it make sense to just assume that the result should be wrapped like this if it's conformable to the other level of the MultiIndex? Too much of a special case?

Comment From: jtratner

Can you try this on my PR (#4039) and see if it works for you? If so, this will be resolved in 0.13 :) [you can get it with git remote add jtratner https://www.github.com/jtratner/pandas.git && git co jtratner/fix-multiindex-naming

Comment From: jseabold

Same error.

Comment From: jreback

@jseabold I understand you want to have this 'automagically' work and since the returned object from your function IS the same shape as the input group I agree.

However, right now the logic in apply allows for different shaped objects to be returned and then infers the shape. So I would call this is a bug. (Its a very narrow special case IMO)

Comment From: jtratner

@jseabold too bad...wondered if it was an astype thing ... clearly not.

Comment From: kordek

I've just came across this issue, if transform is used instead of apply this gives the desired output. So maybe this can be closed?

Comment From: jreback

@kordek this should still work on .apply though. want to look at doing a patch?

generally .transform is much more strict on its output shape and not very flexible, while .apply tries to infer things, which in this case it could do a better job.

Comment From: kordek

@jreback I see, I'll work on this.

Comment From: jreback

closing as Panel deprecated