diff --git a/coordinator/ProcessorSurveyUtils.py b/coordinator/ProcessorSurveyUtils.py index 4da2ecc01c4f60c0177def7a2ac6165349b45cd3..23462b774dd3167fb193db936f088edf30af8263 100644 --- a/coordinator/ProcessorSurveyUtils.py +++ b/coordinator/ProcessorSurveyUtils.py @@ -74,10 +74,17 @@ def parse_date(series,name_out='date',fmt_in = '%Y-%m-%d',fmt_out= '%b %d, %Y'): return s_out -def parse_cases(series, name_out, cases, dtype = None): +def parse_cases(series, name_out, cases, dtype = None, fillna = None): + if dtype is None: dtype = series.dtype + + # Handle nans explicitly + if fillna is not None: + series.fillna(fillna,inplace=True) + # Converting entries according to a cases dictionary + # nans cannot be handled by map series_out = series.map(cases).astype(dtype) # Renaming series