FAQ | This is a LIVE service | Changelog

Skip to content
Snippets Groups Projects
Commit 026708e7 authored by Dr T. Mona's avatar Dr T. Mona
Browse files

Feat: add parse_cases function.

New function to allow conversion of a series according to a provided dictionary. (Needed for WRT formating.)
parent b467d24e
No related branches found
No related tags found
No related merge requests found
......@@ -74,11 +74,23 @@ 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):
if dtype is None:
dtype = series.dtype
# Converting entries according to a cases dictionary
series_out = series.map(cases).astype(dtype)
# Renaming series
series_out.rename(name_out,inplace=True)
return series_out
# dict of functions callable within coln_parser_dict
# so they can be obtained with a string in coln_parser_dict
func_dict = {
'parse_date' : parse_date,
'parse_location_kobotoolbox' : parse_location_kobotoolbox
'parse_location_kobotoolbox' : parse_location_kobotoolbox,
'parse_cases' : parse_cases
}
def parse_columns(df_in,coln_parser_dict):
......
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