-
Notifications
You must be signed in to change notification settings - Fork 16.5k
[fix] Ensure sunburst column ordering adheres to hierarchy #9011
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] Ensure sunburst column ordering adheres to hierarchy #9011
Conversation
353d036 to
a2c96ac
Compare
| def get_data(self, df: pd.DataFrame) -> VizData: | ||
| fd = self.form_data | ||
| cols = fd.get("groupby") | ||
| cols = fd.get("groupby") or [] |
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.
| cols = fd.get("groupby") or [] | |
| cols = fd.get("groupby", []) |
| # Re-order the columns as the query result set column ordering may differ from | ||
| # that listed in the hierarchy. | ||
| df = df[cols] | ||
| return df.to_numpy().tolist() |
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.
.values.tolist()?
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.
@serenajiang per the documentation they mention,
Warning We recommend using DataFrame.to_numpy() instead.
williaster
left a comment
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.
thanks @john-bodley !
CATEGORY
Choose one
SUMMARY
This PR fixes an issue where the values for the sunburst chart (which takes in a list of lists order by the hierarchical columns) were being named incorrectly. The reason being is the resulting
pandas.DataFramecolumn ordering is not the same as the ordering defined in the hierarchy.The fix is to simply re-order the
pandas.DataFramecolumns to adhere to the column ordering specified in the hierarchy.BEFORE/AFTER SCREENSHOTS OR ANIMATED GIF
TEST PLAN
Tested locally for a chart where there were more than one hierarchies defined and confirmed that the ordering of the layers in the chart were correct.
ADDITIONAL INFORMATION
REVIEWERS
to: @etr2460 @mistercrunch @williaster