Skip to content

Updating generic.py error message #8618

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 33 commits into from
Closed

Updating generic.py error message #8618

wants to merge 33 commits into from

Conversation

springcoil
Copy link
Contributor

This is my first attempt at a PR. I just made a little change to allow an error message. Would appreciate some feedback.
closes #8015

return groupby(self, by, axis=axis, level=level, as_index=as_index,
sort=sort, group_keys=group_keys, squeeze=squeeze)
except AttributeError:
raise TypeError('You have to at least specify one of by or level')
Copy link
Member

Choose a reason for hiding this comment

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

can you quote by and level ? (so "You ... 'by' or 'level'"), then it is more clear it are the keywords

@jorisvandenbossche
Copy link
Member

Thanks for the PR!

Strange, for some reason Travis is not triggered to run the test suite.

@springcoil
Copy link
Contributor Author

Hi Joris,
I just realized I was a bit tired yesterday when I wrote all of this without triggering the travis test suite.
I will add that and update above.

@jreback jreback added the Error Reporting Incorrect or improved errors from pandas label Oct 24, 2014
@jreback jreback added this to the 0.15.1 milestone Oct 24, 2014
@springcoil
Copy link
Contributor Author

Updated based on your previous comments Joris. Let me know what you think.

@jreback
Copy link
Contributor

jreback commented Oct 27, 2014

going to need a specific test to validate this new behavior (eg need to hit and validate each of the branches)

model after assertRaisesRegex usage

@springcoil
Copy link
Contributor Author

Any suggestion what I test for - just by each argument?

@jreback
Copy link
Contributor

jreback commented Oct 27, 2014

someting like (error message should match, this was off the cuff)

def f():
     df.groupby()
self.assertRaisesRegexp(TypeError, f, "You have to supply one of 'by' or 'level'")

so should have 4 tests to cover
put in tests/test_groupby.py (their might be some existing tests, put with those)

@springcoil
Copy link
Contributor Author

Let me know if this works or not. I had some travis CI problems. Submitting a new build

@springcoil
Copy link
Contributor Author

The updated code is added included the tests. It passes the Travis CI build

@@ -1981,6 +1993,32 @@ def test_groupby_level_apply(self):
result = frame['A'].groupby(level=0).count()
self.assertEqual(result.index.name, 'first')

def g():
Copy link
Contributor

Choose a reason for hiding this comment

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

just put all of these under one new function (the 4 tests), maybe test_groupby_args

Copy link
Contributor

Choose a reason for hiding this comment

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

add the issue number as a comment

@jreback
Copy link
Contributor

jreback commented Oct 27, 2014

see git help here:https://github.com/pydata/pandas/wiki/Using-Git

just rebase the offending commit away and force push

@springcoil
Copy link
Contributor Author

any update?

@jreback
Copy link
Contributor

jreback commented Oct 29, 2014

hmm, it seems you have lost the actual change you made. The tests are there though.

@springcoil
Copy link
Contributor Author

Sorting it out now :)

On Thu, Oct 30, 2014 at 12:17 AM, jreback notifications@github.com wrote:

hmm, it seems you have lost the actual change you made. The tests are
there though.


Reply to this email directly or view it on GitHub
#8618 (comment).

Peadar Coyle
Skype: springcoilarch
www.twitter.com/springcoil
peadarcoyle.wordpress.com

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

Choose a reason for hiding this comment

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

The assert should not be in the function definition, as in this way it is not called:

def g():
    frame.groupby(..)
self.assert ...

@jreback jreback modified the milestones: 0.15.2, 0.15.1 Oct 30, 2014
@springcoil
Copy link
Contributor Author

@hayd Hey Andy, I was having a look at this - andd got some feedback (bad tests the first time I submitted). I'm trying to figure out a way to test for df.groupby() as we all agree that should return an error. But I keep running into the errors above in my tests. Any suggestions?

jreback and others added 14 commits November 27, 2014 12:48
Fix unrecognized 'Z' UTC designator
For consistency with [PEP8][1]:

    Imports are always put at the top of the file, just after any module
    comments and docstrings, and before module globals and constants.

[1]: https://www.python.org/dev/peps/pep-0008#id17
Option context no longer overrides options when used outside a `with`
statement.

Added test TestConfig.test_option_config_scope

Closes #8514
$ nosetests pandas/core/common.py --with-doc -v
BUG: DatetimeIndex with time object as key
Categorical: let unique only return used categories
@jreback
Copy link
Contributor

jreback commented Nov 30, 2014

@springcoil ?

@springcoil
Copy link
Contributor Author

Sorry @jreback just rebasing and submitting now.

@springcoil
Copy link
Contributor Author

Still getting some test failures - but none seem related my own code... I'm a bit confused. Does anyone have any advice?

@jorisvandenbossche
Copy link
Member

You have included a lot of other commits, maybe something there is causing the errors. Can you do on your branch:

git fetch upstream
git rebase upstream/master
git push -f origin PR8015

@springcoil springcoil closed this Dec 1, 2014
@springcoil springcoil deleted the PR8015 branch December 1, 2014 08:13
@springcoil
Copy link
Contributor Author

Deleting this branch - starting again - with a new one, this might make it easier.
See #8950

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
Projects
None yet
Development

Successfully merging this pull request may close these issues.

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