FAQ | This is a LIVE service | Changelog

Skip to content
Snippets Groups Projects
Commit 66fff212 authored by J.W. Smith's avatar J.W. Smith
Browse files

feat: More robust survey preprocessing

parent 75955d76
No related branches found
No related tags found
No related merge requests found
......@@ -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
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment