-
-
Notifications
You must be signed in to change notification settings - Fork 18.5k
BUG: correct wrong error message in df.pivot when columns=None #30925
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
Changes from 6 commits
7e461a1
1314059
8bcb313
776e9ae
4895497
f4380cd
e60ffee
61ac061
d03452f
abce670
28d3d41
c650a05
16478e5
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change | ||||
---|---|---|---|---|---|---|
|
@@ -781,6 +781,15 @@ def test_pivot_with_list_like_values_nans(self, values, method): | |||||
expected = DataFrame(data=data, index=index, columns=columns, dtype="object") | ||||||
tm.assert_frame_equal(result, expected) | ||||||
|
||||||
def test_pivot_columns_none_raise_error(self): | ||||||
# GH 30924 | ||||||
df = pd.DataFrame( | ||||||
{"col1": ["a", "b", "c"], "col2": [1, 2, 3], "col3": [1, 2, 3]} | ||||||
) | ||||||
msg = 'pivot["(][")] missing 1 required argument: ["\']columns["\']' | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. if you use re.escape, this may be more readable. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. thanks for your quick response, i tried There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
also need to import re There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. ahh, i see!!! thanks! @simonjayhawkins |
||||||
with pytest.raises(ValueError, match=msg): | ||||||
df.pivot(index="col1", values="col3") | ||||||
|
||||||
@pytest.mark.xfail( | ||||||
reason="MultiIndexed unstack with tuple names fails with KeyError GH#19966" | ||||||
) | ||||||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This should be a TypeError no? I think @simonjayhawkins had that original comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
sorry, i thought
ValueError
is more appropriate here for this case.I changed to
TypeError
as suggested by @simonjayhawkins ! thanks both!There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think it should be TypeError, however, I would regard a change from ValueError to TypeError as a breaking change. Not sure what others think.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nvm. The exception in the issue is a KeyError, so either is a change.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
get it! thanks!