kakoni opened a new issue #11658:
URL: https://github.com/apache/incubator-superset/issues/11658


   Commit 
https://github.com/apache/incubator-superset/commit/fc28c92f57edd7bccac57715bef159c0f18daef1
 introduced new 
[get_aggfunc](https://github.com/apache/incubator-superset/blob/master/superset/viz.py#L875-L879)
 method to pick right aggregation function (especially when working with 
non-numeric columns)
   
   Unfortunately this method fails when using postgres/psycopg based data, as 
sum columns are returned as psql numeric type which psycopg maps into python 
`decimal` type. Pandas/Numpy doesnt seem to work that well with `decimal` type 
(example;  `dtype` returns `object` for `decimal`).
   
   Main culprit here is  `pd.api.types.is_numeric_dtype` which obviously 
returns `False` for `decimal` type. 
   
   So perhaps as a fix I propose something like 
   ```
   pd.api.types.is_numeric_dtype(df[metric]) or all(isinstance(x, 
decimal.Decimal) for x in df[metric])
   ```
   
   @villebro Any comments?


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