mistercrunch commented on a change in pull request #4726: [bugfix] convert 
metrics to numeric in dataframe
URL: 
https://github.com/apache/incubator-superset/pull/4726#discussion_r178484892
 
 

 ##########
 File path: superset/viz.py
 ##########
 @@ -170,11 +170,21 @@ def get_df(self, query_obj=None):
                 if self.datasource.offset:
                     df[DTTM_ALIAS] += timedelta(hours=self.datasource.offset)
                 df[DTTM_ALIAS] += self.time_shift
+
+            self.df_metrics_to_num(df, query_obj.get('metrics') or [])
+
             df.replace([np.inf, -np.inf], np.nan)
             fillna = self.get_fillna_for_columns(df.columns)
             df = df.fillna(fillna)
         return df
 
+    @staticmethod
+    def df_metrics_to_num(df, metrics):
+        """Converting metrics to numeric when pandas.read_sql cannot"""
+        for col, dtype in df.dtypes.iteritems():
 
 Review comment:
   That's right. I got confused as I copied the code over and though it must 
have been backported for compatibility reasons. I'll grep and remove other 
instances of it where I copied it from.

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
[email protected]


With regards,
Apache Git Services

Reply via email to