Commit bedcc066 authored by Paul McCarthy's avatar Paul McCarthy 🚵
Browse files

RF: Convert columns to type appropriate to each variable/datafield

parent ba9426da
......@@ -565,6 +565,28 @@ def loadVariableTable(
['ParentValues', 'ChildValues'],
# navalues, raw/new levels and child values
# are all still comma-separated strings -
# convert them to types appropriate to the
# datafield/variable
def convert(rowvalues, column):
val = rowvalues[column]
if pd.isna(val):
return np.nan
val = convert_comma_sep_text(val)
ctype = rowvalues['Type']
dtype = util.DATA_TYPES.get(ctype, None)
if ctype in (, util.CTYPES.time):
return pd.to_datetime(val).values
return np.array(val, dtype=dtype)
for col in ('NAValues', 'RawLevels', 'NewLevels', 'ChildValues'):
vartable[col] = vartable.apply(convert, axis=1, args=(col,))
# Before merging the cleaning functions
# in, we generate a list of variables
# which are "uncleaned", i.e. have not
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment