-
-
Notifications
You must be signed in to change notification settings - Fork 18.4k
Fix pivot index bug #37771
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
Fix pivot index bug #37771
Changes from 3 commits
46821e8
9a7a60a
edebfaa
6fbebe4
d673a9d
5833b33
51acab0
752ca20
4cff34b
2e249c9
9e9ed00
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 |
---|---|---|
|
@@ -2153,3 +2153,20 @@ def test_pivot_index_none(self): | |
|
||
expected.columns.name = "columns" | ||
tm.assert_frame_equal(result, expected) | ||
|
||
def test_pivot_index_list_values_none(self): | ||
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. call it |
||
# Tests when index is a list and values None. See GH#37635 | ||
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. just do # GH37635 |
||
data = { | ||
"index": ["A", "B", "C", "C", "B", "A"], | ||
"columns": ["One", "One", "One", "Two", "Two", "Two"], | ||
"values": [1.0, 2.0, 3.0, 3.0, 2.0, 1.0], | ||
} | ||
index = ["index"] | ||
columns = ["columns"] | ||
frame = DataFrame(data) | ||
frame.pivot(index=index, columns=columns, values=None) | ||
|
||
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. check here that you got the correct result from the pivot (might need to hard-code) |
||
expected_ser = Series(["index"]) | ||
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. Why are you converting to Series? you want to check that 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. Was trying to use the assert functions in 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. yes use a standard assert here |
||
result_ser = Series(index) | ||
|
||
tm.assert_series_equal(result_ser, expected_ser) |
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 might be wrong but I don't think this is testing the OP...?
I'd use the example from the issue. Do the pivot and test the result of the pivot operation, then test that the arguments have not changed
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.
Actually definitely use that. This isn't quite the same use case