villebro commented on a change in pull request #11018:
URL: 
https://github.com/apache/incubator-superset/pull/11018#discussion_r494172137



##########
File path: superset/viz.py
##########
@@ -3014,23 +3014,25 @@ def nest_values(
                 for m in levels[0].index
             ]
         if level == 1:
+            metric_level = levels[1][metric]
             return [
                 {
                     "name": i,
-                    "val": levels[1][metric][i],
+                    "val": metric_level[i],
                     "children": self.nest_values(levels, 2, metric, [i]),
                 }
-                for i in levels[1][metric].index
+                for i in metric_level.index
             ]
         if level >= len(levels):
             return []
+        dim_level = levels[level][metric][[dims[0]]]

Review comment:
       This logic has changed as of `pandas>=1.1`: previously additional keys 
in a nested `MultiIndex` were ignored, now they cause a `KeyError`. The correct 
behavior for this in this context is to just use the first index. So where we 
were previously able to do `levels[level][metric][dims]`, now we must do 
`levels[level][metric][[dims[0]]]`.

##########
File path: superset/viz.py
##########
@@ -3014,23 +3014,25 @@ def nest_values(
                 for m in levels[0].index
             ]
         if level == 1:
+            metric_level = levels[1][metric]
             return [
                 {
                     "name": i,
-                    "val": levels[1][metric][i],
+                    "val": metric_level[i],
                     "children": self.nest_values(levels, 2, metric, [i]),
                 }
-                for i in levels[1][metric].index
+                for i in metric_level.index
             ]
         if level >= len(levels):
             return []
+        dim_level = levels[level][metric][[dims[0]]]

Review comment:
       Note to self (in case this causes a regression): 
`levels[level][metric][[dims[-1]]]` should produce the same result.




----------------------------------------------------------------
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.

For queries about this service, please contact Infrastructure at:
[email protected]



---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to