out_cols = X.columns.values
cols = []
mapped_columns = []
for switch in mapping:
col = switch.get("col")
mod = switch.get("mapping")
cols.append(col)
X[col] = 0
for column_mapping in mod:
existing_col = column_mapping.get("new_col_name")
val = column_mapping.get("val")
X.loc[X[existing_col] == 1, col] = val
mapped_columns.append(existing_col)
out_cols = [col0 for col0 in out_cols if col0 not in mapped_columns]
return X.reindex(columns=out_cols + cols)