-
-
Notifications
You must be signed in to change notification settings - Fork 18.5k
Pivot table margins brittleness #3334
New issue
Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? # to your account
Comments
I've traced this bug to the type of index we have on the columns of the pivoted table. The pivoted table is first constructed here: https://github.com/pydata/pandas/blob/master/pandas/tools/pivot.py#L100 If the rows and columns account for the entire frame, then the index is a single level index. Otherwise, it's multilevel with nlevels=2. This difference causes problems later when we group by column: https://github.com/pydata/pandas/blob/master/pandas/tools/pivot.py#L156 Rather than grouping by level 0 of a multi-index, we are grouping by the only level in a single index. This picks up a particular value in a column rather than the level 0 value in the index, which was the name of a column. I'll try to push a fix tomorrow or the next day pending time to work on it. We may need to handle this case specially. |
I guess the most obvious question is whether a suitable fix is to append an extra column of ones if rows + cols is the entire DataFrame. Thoughts? |
…_table Adds support for margin computation when all columns are used in rows and cols.
Adds support for margin computation when all columns are used in rows and cols
…_table Adds support for margin computation when all columns are used in rows and cols.
…_table Adds support for margin computation when all columns are used in rows and cols.
Adds support for margin computation when all columns are used in rows and cols. DOC: Fixed release notes BUG: Fixed failing test due to use of basestring in python 3
closed via #4432 |
The text was updated successfully, but these errors were encountered: