Skip to content

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

Merged
merged 11 commits into from
Jan 17, 2020

Conversation

charlesdong1991
Copy link
Member

@simonjayhawkins simonjayhawkins added Bug Reshaping Concat, Merge/Join, Stack/Unstack, Explode labels Jan 13, 2020
@simonjayhawkins simonjayhawkins added this to the 1.1 milestone Jan 13, 2020
@@ -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",
Copy link
Member

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

Copy link
Member Author

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

Copy link
Contributor

@jreback jreback left a 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.

@@ -596,6 +598,11 @@ def crosstab(
**kwargs,
)

# Remove extra level from `[__dummy__]` pivoting
Copy link
Contributor

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.

@charlesdong1991
Copy link
Member Author

ping @jreback

@WillAyd WillAyd merged commit a890239 into pandas-dev:master Jan 17, 2020
@WillAyd
Copy link
Member

WillAyd commented Jan 17, 2020

Thanks @charlesdong1991

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug Reshaping Concat, Merge/Join, Stack/Unstack, Explode
Projects
None yet
Development

Successfully merging this pull request may close these issues.

pd.crosstab(s1, s2) keeps dummy MultiIndex as columns if both s1 and s2 have tuple name
4 participants