amaannawab923 commented on PR #33656:
URL: https://github.com/apache/superset/pull/33656#issuecomment-2948982898
Went through the pr
I had some input for this , there might be an easier solution for this... We
can just pass a flag to contribution operator that it should use total of a
metric value while Calculating the percentage instead of the Usual Sum of a
column
The current implementation in contribution.py is
if orientation == PostProcessingContributionOrientation.COLUMN:
numeric_df_view = numeric_df_view / numeric_df_view.values.sum(
axis=0, keepdims=True
)
contribution_df[rename_columns] = numeric_df_view
return contribution_df
And then we can do it like this
if orientation == PostProcessingContributionOrientation.COLUMN:
if contribution_totals:
# Use pre-calculated totals for division
for col in numeric_df_view.columns:
if col in contribution_totals:
numeric_df_view[col] = numeric_df_view[col] /
contribution_totals[col] <- Using existing contribution_total pre calculated
ones
else:
# Use existing column sum logic
numeric_df_view = numeric_df_view / numeric_df_view.values.sum(
axis=0, keepdims=True
)
contribution_df[rename_columns] = numeric_df_view
return contribution_df
i agree with @betodealmeida & @Antonio-RiveroMartnez that since
query_context_processor is the center of query context processing it shouldnt
be touched but instead we can reuse the existing contribution operator .... Let
me know if that makes sense...But i guess reusing existing operator will reduce
the code changes by a huge scale
cc: @geido @LevisNgigi
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]