-
-
Notifications
You must be signed in to change notification settings - Fork 18.4k
BUG: pd.crosstab(s1, s2) handle column index incorrectly when both series have tuple names #30978
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
Conversation
pandas/tests/reshape/test_pivot.py
Outdated
@@ -2549,6 +2549,53 @@ def test_crosstab_tuple_name(self, names): | |||
result = pd.crosstab(s1, s2) | |||
tm.assert_frame_equal(result, expected) | |||
|
|||
@pytest.mark.parametrize( | |||
"s1_data, s1_name, s2_data, s2_name, " | |||
"expected_index, expected_column, expected_data", |
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.
what is the unique feature between these sets of parameters you are trying to test? Wasn't immediately clear to me; may be OK to do without it if it simplifies test
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.
yeah, removed. the unique feature was different shape of output, and with one of index
or column
having same value, like [1,1,1]
, but probably made it unclear. I now just used the example described in the issue
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.
lgtm. minor comment, pls rebase as well.
pandas/core/reshape/pivot.py
Outdated
@@ -596,6 +598,11 @@ def crosstab( | |||
**kwargs, | |||
) | |||
|
|||
# Remove extra level from `[__dummy__]` pivoting |
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.
can you give a comment on why you are doing this.
ping @jreback |
Thanks @charlesdong1991 |
black pandas
git diff upstream/master -u -- "*.py" | flake8 --diff