You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@superset.apache.org by GitBox <gi...@apache.org> on 2020/06/09 16:40:52 UTC

[GitHub] [incubator-superset] serenajiang commented on a change in pull request #10003: fix(SankeyViz): enforce source/target order

serenajiang commented on a change in pull request #10003:
URL: https://github.com/apache/incubator-superset/pull/10003#discussion_r436859342



##########
File path: superset/viz.py
##########
@@ -1737,7 +1737,14 @@ def query_obj(self):
         return qry
 
     def get_data(self, df: pd.DataFrame) -> VizData:
-        df.columns = ["source", "target", "value"]
+        df.rename(
+            columns={
+                self.form_data["groupby"][0]: "source",
+                self.form_data["groupby"][1]: "target",
+                df.columns[-1]: "value",
+            },
+            inplace=True,
+        )

Review comment:
       `self.form_data["metric"]` does not seem to always be a string (e.g. if the metric is custom defined like `COUNT(col_1)`).

##########
File path: superset/viz.py
##########
@@ -1737,7 +1737,14 @@ def query_obj(self):
         return qry
 
     def get_data(self, df: pd.DataFrame) -> VizData:
-        df.columns = ["source", "target", "value"]
+        df.rename(
+            columns={
+                self.form_data["groupby"][0]: "source",
+                self.form_data["groupby"][1]: "target",
+                df.columns[-1]: "value",
+            },
+            inplace=True,
+        )

Review comment:
       @ktmud I altered it to use `self.groupby` and `self.metric_labels` (thanks for tip!)
   
   I think I'll keep this PR specific to `SankeyViz`. I looked briefly into `ChordViz` and it looks like ChordViz uses a different metadata format, so this change might not be necessary.




----------------------------------------------------------------
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:
users@infra.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For additional commands, e-mail: notifications-help@superset.apache.org