-
Notifications
You must be signed in to change notification settings - Fork 14k
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: allow for multiple columns in pivot table report #17636
Conversation
Codecov Report
@@ Coverage Diff @@
## master #17636 +/- ##
==========================================
- Coverage 76.81% 76.73% -0.08%
==========================================
Files 1049 1062 +13
Lines 56653 57005 +352
Branches 7847 7847
==========================================
+ Hits 43517 43745 +228
- Misses 12883 13007 +124
Partials 253 253
Flags with carried forward coverage won't be shown. Click here to find out more.
Continue to review full report at Codecov.
|
7bcd548
to
e382dea
Compare
06ae866
to
f69b8ac
Compare
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.
6 lines of code, 583 of tests! <3
Co-authored-by: Beto Dealmeida <[email protected]>
Props to you for writing the original tests. :) This code was very easy to work with as a result! |
SUMMARY
This fixes a 500 error when running a pivot table v2 report on a chart with multiple columns and no rows
On a pandas dataframe stack function:
if the columns have a single level, the output is a Series;
if the columns have multiple levels, the new index level(s) is (are) taken from the prescribed level(s) and the output is a DataFrame.
For a chart with multiple columns, a dataframe does not have the
to_frame
method, and was erroring.This pr checks for the return type of
stack
before callingto_frame
Second fix: some charts that have null values were having problems when pivoting because pandas will drop some data and then later filtering and manipulation can cause errors. I resolved this by filling in null values with a "NULL" string.
*some work still needs to be done to improve the formatting of a pivot chart report with multiple columns.
TESTING INSTRUCTIONS
Create a chart with pivot v2 with multiple columns and no rows and make sure that a chart as both a csv and table can be sent as a report.
Create a pivot v2 chart with a column of all null values and select that as a chart column. Reports should send correctly for csv and test.
ADDITIONAL INFORMATION