Refactor NULL handling into method, disable for DECK.gl vizes (#5106)

This commit is contained in:
Maxime Beauchemin 2018-05-31 16:01:49 -07:00 committed by GitHub
parent ff4b103025
commit 28611108d7
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 8 additions and 2 deletions

View File

@ -145,6 +145,10 @@ class BaseViz(object):
"""
pass
def handle_nulls(self, df):
fillna = self.get_fillna_for_columns(df.columns)
df = df.fillna(fillna)
def get_fillna_for_col(self, col):
"""Returns the value for use as filler for a specific Column.type"""
if col:
@ -208,8 +212,7 @@ class BaseViz(object):
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)
self.handle_nulls(df)
return df
@staticmethod
@ -2041,6 +2044,9 @@ class BaseDeckGLViz(BaseViz):
credits = '<a href="https://uber.github.io/deck.gl/">deck.gl</a>'
spatial_control_keys = []
def handle_nulls(self, df):
pass
def get_metrics(self):
self.metric = self.form_data.get('size')
return [self.metric] if self.metric else []