Skip to content

Updating generic.py error message #8618 - New branch #8950

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 1 commit into from
Closed

Updating generic.py error message #8618 - New branch #8950

wants to merge 1 commit into from

Conversation

springcoil
Copy link
Contributor

closes #8015

I deleted the previous branch that was causing problems and submitted this.
This is my first attempt at a PR. I just made a little change to allow an error message. Would appreciate some feedback.
@jreback @jorisvandenbossche @hayd

@jorisvandenbossche
Copy link
Member

@springcoil That are not the errors that I see on travis. These tests are failing:

======================================================================
ERROR: test_cumcount_empty (pandas.tests.test_groupby.TestGroupBy)
----------------------------------------------------------------------
Traceback (most recent call last):
File "/home/travis/build/pydata/pandas/pandas/tests/test_groupby.py", line 3703, in test_cumcount_empty
ge = DataFrame().groupby()
File "/home/travis/build/pydata/pandas/pandas/core/generic.py", line 2878, in groupby
raise TypeError('You have to specify at least one of "by" and "level"')

TypeError: You have to specify at least one of "by" and "level"

======================================================================
ERROR: test_groupby_args (pandas.tests.test_groupby.TestGroupBy)
----------------------------------------------------------------------
Traceback (most recent call last):
File "/home/travis/build/pydata/pandas/pandas/tests/test_groupby.py", line 2011, in test_groupby_args
self.assertRaisesRegexp(TypeError, k, "You have to supply one of 'by' and 'level'")
File "/home/travis/build/pydata/pandas/pandas/util/testing.py", line 1596, in assertRaisesRegexp
manager = _AssertRaisesContextmanager(exception=_exception, regexp=_regexp)
File "/home/travis/build/pydata/pandas/pandas/util/testing.py", line 1609, in __init__
regexp = re.compile(regexp)
File "/home/travis/miniconda/envs/pandas/lib/python2.7/re.py", line 190, in compile
return _compile(pattern, flags)
File "/home/travis/miniconda/envs/pandas/lib/python2.7/re.py", line 240, in _compile
raise TypeError, "first argument must be string or compiled pattern"

TypeError: first argument must be string or compiled pattern

@springcoil
Copy link
Contributor Author

The tests pass :) Can we merge now?


def k():
frame.groupby(by=None, level=None)
self.assertRaisesRegexp(TypeError, "You have to supply one of 'by' and 'level'")
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You removed the k function in the assert, so this is not testing the groupby anymore

@springcoil
Copy link
Contributor Author

Ok second attempt :)

ge = DataFrame().groupby()
se = Series().groupby()
ge = DataFrame().groupby(level=0)
se = Series().groupby(level=0)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@jreback this test was introduced in #5510, but I think it is ok to change it, as it is mainly testing the empty frame, not the empty groupby call.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I agree empty just raise (as it is tested above)

@jorisvandenbossche
Copy link
Member

@springcoil Could you squash?

You can do this with:

git fetch upstream
git rebase -i upstream/master
git push -f origin PR8015_springcoil

and then change 'pick' into 'fixup' apart for the first commit.

@springcoil
Copy link
Contributor Author

Hi @jorisvandenbossche thanks for the squash reminder. I Squashed it and commited the new code.
I hope all is well now.
Thanks also for confirmation it was ok to change a few of the tests, as I needed to get them to pass.

@jreback jreback added Error Reporting Incorrect or improved errors from pandas Groupby labels Dec 3, 2014
@jreback jreback added this to the 0.15.2 milestone Dec 3, 2014
@jreback
Copy link
Contributor

jreback commented Dec 3, 2014

merged via 2ed182e

thanks! I know it was an experience, but the first PR is always the hardest.

@springcoil
Copy link
Contributor Author

Thanks :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Error Reporting Incorrect or improved errors from pandas Groupby
Projects
None yet
Development

Successfully merging this pull request may close these issues.

pd.Series.groupby is said to have only optional parameters
3 participants