You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@superset.apache.org by ma...@apache.org on 2017/09/12 16:36:31 UTC
[incubator-superset] branch master updated: Handling pandas
ExtensionDtypes (#2937)
This is an automated email from the ASF dual-hosted git repository.
maximebeauchemin pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/incubator-superset.git
The following commit(s) were added to refs/heads/master by this push:
new 490c707 Handling pandas ExtensionDtypes (#2937)
490c707 is described below
commit 490c707eb67c0497d1d70d2204a6919218d1f526
Author: fabianmenges <fa...@users.noreply.github.com>
AuthorDate: Tue Sep 12 12:36:28 2017 -0400
Handling pandas ExtensionDtypes (#2937)
---
superset/dataframe.py | 8 +++++++-
1 file changed, 7 insertions(+), 1 deletion(-)
diff --git a/superset/dataframe.py b/superset/dataframe.py
index f3b9f3e..66034bb 100644
--- a/superset/dataframe.py
+++ b/superset/dataframe.py
@@ -14,6 +14,8 @@ from datetime import datetime, date
from past.builtins import basestring
import pandas as pd
+from pandas.core.dtypes.dtypes import ExtensionDtype
+
import numpy as np
@@ -52,6 +54,8 @@ class SupersetDataFrame(object):
@classmethod
def db_type(cls, dtype):
"""Given a numpy dtype, Returns a generic database type"""
+ if isinstance(dtype, ExtensionDtype):
+ return cls.type_map.get(dtype.kind)
return cls.type_map.get(dtype.char)
@classmethod
@@ -87,8 +91,10 @@ class SupersetDataFrame(object):
# consider checking for key substring too.
if cls.is_id(column_name):
return 'count_distinct'
- if np.issubdtype(dtype, np.number):
+ if (issubclass(dtype.type, np.generic) and
+ np.issubdtype(dtype, np.number)):
return 'sum'
+ return None
@property
def columns(self):
--
To stop receiving notification emails like this one, please contact
['"commits@superset.apache.org" <co...@superset.apache.org>'].