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 2019/04/23 00:37:10 UTC

[GitHub] [incubator-superset] zhaoyongjie commented on a change in pull request #7325: [Viz] transpose pivot table

zhaoyongjie commented on a change in pull request #7325: [Viz] transpose pivot table
URL: https://github.com/apache/incubator-superset/pull/7325#discussion_r277483933
 
 

 ##########
 File path: superset/viz.py
 ##########
 @@ -681,9 +687,13 @@ def get_data(self, df):
         if aggfunc == 'sum':
             aggfunc = lambda x: x.sum(min_count=1)  # noqa: E731
 
+        groupby = self.form_data.get('groupby')
+        columns = self.form_data.get('columns')
+        if self.form_data.get('transpose_pivot'):
+            groupby, columns = columns, groupby
         df = df.pivot_table(
-            index=self.form_data.get('groupby'),
-            columns=self.form_data.get('columns'),
+            index=groupby,
 
 Review comment:
   Hi, Max, if we use df = df.T transpose pivot table, the metric columns will also rotate, 
   this can cause problems for rendering dataframe html, such as columns out of cellindex.(Because there will be spaces cell on the column)
   
   ### original table
   ![image](https://user-images.githubusercontent.com/2016594/56542802-24526e00-65a2-11e9-923d-c42e6a8b995b.png)
   
   ### when df.T
   ![image](https://user-images.githubusercontent.com/2016594/56542819-2caaa900-65a2-11e9-9902-5881c1766455.png)
   

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


With regards,
Apache Git Services

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