-
-
Notifications
You must be signed in to change notification settings - Fork 18.4k
BUG: pd.crosstab fails when passed multiple columns, margins True and normalize True #35150
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
jreback
merged 11 commits into
pandas-dev:master
from
CloseChoice:fix_normalize_crosstabbing
Aug 19, 2020
Merged
Changes from 3 commits
Commits
Show all changes
11 commits
Select commit
Hold shift + click to select a range
b31e07a
correct wrong if statement in crosstab and add tests for #35144
CloseChoice df57d87
pass "black pandas"
CloseChoice 01217bc
add whatsnew entry, update comment and unit tests in test_crosstab.py
CloseChoice e0c63d1
Merge branch 'master' into fix_normalize_crosstabbing
CloseChoice 05303bb
split up tests
CloseChoice 450390a
Merge branch 'master' of https://github.com/pandas-dev/pandas into fi…
CloseChoice 9f7356a
Merge branch 'master' of https://github.com/pandas-dev/pandas into fi…
CloseChoice bb00a4b
add whatsnew/v1.2.0.rst entry
CloseChoice fa48fff
assign variable for duplicated call to last index or column
CloseChoice f33e23d
apply `black pandas`
CloseChoice fb712e5
Merge branch 'master' of https://github.com/pandas-dev/pandas into fi…
CloseChoice File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -671,9 +671,9 @@ def _normalize(table, normalize, margins: bool, margins_name="All"): | |
table_index = table.index | ||
table_columns = table.columns | ||
|
||
# check if margin name is in (for MI cases) or equal to last | ||
# check if margin name is not in (for MI cases) and not equal to last | ||
# index/column and save the column and index margin | ||
if (margins_name not in table.iloc[-1, :].name) | ( | ||
if (margins_name not in table.iloc[-1, :].name) & ( | ||
jreback marked this conversation as resolved.
Show resolved
Hide resolved
jreback marked this conversation as resolved.
Show resolved
Hide resolved
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. can you pull out 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. done |
||
margins_name != table.iloc[:, -1].name | ||
): | ||
raise ValueError(f"{margins_name} not in pivoted DataFrame") | ||
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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 move to 1.2