Updating generic.py error message

This is my first attempt at a PR. I just made a little change to allow an error message. Would appreciate some feedback. 
Based on https://github.com/pydata/pandas/issues/8015
Any suggestions on improving this logic?
Obviously I want to check if levels are not none, Do I just remove the if
axis is not None: branch and proceed with the rest?
I'll try it.

On Thu, Oct 30, 2014 at 10:54 AM, Joris Van den Bossche <
notifications@github.com> wrote:

> In pandas/core/generic.py:
>
> > @@ -2868,9 +2868,17 @@ def groupby(self, by=None, axis=0, level=None, as_index=True, sort=True,
> >          """
> >
> >          from pandas.core.groupby import groupby
> > -        axis = self._get_axis_number(axis)
> > -        return groupby(self, by, axis=axis, level=level, as_index=as_index,
> > -                       sort=sort, group_keys=group_keys, squeeze=squeeze)
> > +        if axis is not None:
> > +            axis = self._get_axis_number(axis)
> > +            return groupby(self, by, axis=axis, level=level, as_index=as_index,
> > +                        sort=sort, group_keys=group_keys, squeeze=squeeze)
> > +        elif level is not None:
> > +            raise TypeError('You have to specify one of "by" or "level"')
> > +        elif by is not None:
> > +            raise TypeError('You have to specify one of "by" or "level"')
> > +        else:
> > +            raise TypeError('You have to specify one of "by" or "level"')
>
> I don't really understand the logic here. You first test for axis is not
> None, which will almost always be the case (as axis has a default value
> of 0), and only afterwards you test if level and/or by are not None. But
> I think you will never get there since if axis is not None will give True?
>
> —
> Reply to this email directly or view it on GitHub
> <https://github.com/pydata/pandas/pull/8618/files#r19595108>.
>



-- 
Peadar Coyle
Skype: springcoilarch
www.twitter.com/springcoil
peadarcoyle.wordpress.com