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 2021/07/31 08:41:08 UTC

[GitHub] [superset] zhaoyongjie commented on pull request #15975: fix: eliminate cartesian product columns in pivot operator

zhaoyongjie commented on pull request #15975:
URL: https://github.com/apache/superset/pull/15975#issuecomment-890312917


   > Thanks for addressing this! ❤️
   > 
   > One minor comment. Also just wondering - would `dropna(how="all", ...)` on the final result work as a simpler solution?
   
   sorry, missing this review. `dropna with all` might be Ignore `NULL` value of metric, for instance
   ```
   import pandas as pd
   import numpy as np
   from datetime import datetime
   
   df = pd.DataFrame({
       "ds": [datetime(2012, 11, 1), datetime(2012, 11, 1)],
       "col1": ['a', 'b'],
       "col2": ['a', 'b'],
       "metric": [np.NaN, 9], #<--- metric values
   })
   df
   
     | ds | col1 | col2 | metric
   -- | -- | -- | -- | --
   2012-11-01 | a | a | NaN
   2012-11-01 | b | b | 9.0
   
   df = df.pivot_table(
       index="ds",
       columns=["col1", "col2"],
       values=["metric"],
       aggfunc={
        "metric": np.mean
       },
       dropna=False
   )
   
   df.dropna(how="all", axis=1)
   
   
   
     | metric
   -- | --
   9.0
   ```
   
   
   


-- 
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: notifications-unsubscribe@superset.apache.org

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