Skip to content

Commit

Permalink
[bugfix] 'No numeric types to aggregate' in NVD3 chart (apache#5853)
Browse files Browse the repository at this point in the history
(cherry picked from commit 73cfccc)
  • Loading branch information
mistercrunch authored and betodealmeida committed Oct 30, 2018
1 parent c6ac759 commit fbbbfc1
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions superset/viz.py
Original file line number Diff line number Diff line change
Expand Up @@ -227,15 +227,15 @@ def get_df(self, query_obj=None):
df[DTTM_ALIAS] += self.time_shift

if self.enforce_numerical_metrics:
self.df_metrics_to_num(df, query_obj.get('metrics') or [])
self.df_metrics_to_num(df)

df.replace([np.inf, -np.inf], np.nan)
df = self.handle_nulls(df)
return df

@staticmethod
def df_metrics_to_num(df, metrics):
def df_metrics_to_num(self, df):
"""Converting metrics to numeric when pandas.read_sql cannot"""
metrics = self.metric_labels
for col, dtype in df.dtypes.items():
if dtype.type == np.object_ and col in metrics:
df[col] = pd.to_numeric(df[col], errors='coerce')
Expand Down

0 comments on commit fbbbfc1

Please sign in to comment.