data_df = pd.DataFrame({"AAA": [1, 2, 1, 3],
"BBB": [1, 1, 2, 2],
"CCC": [2, 1, 3, 1]})
lookup_df = pd.DataFrame({"key": [1,2,3], "value" : ["Alpha", "Beta", "Charlie"]})
data_dt = dt.Frame(data_df)
lookup_dt = dt.Frame(lookup_df)
I have these 2 datatables; one containing the data and another containing the lookup values.
I am trying to produce a result datatable with additional columns with lookups done.
For example:
AAA BBB CCC AAA_Category BBB_Category CCC_Category
1 1 2 Alpha Alpha Beta
I can do that by converting the lookup into a list of tuples and doing something like
for name, cond, value in conditions:
data_dt[cond, f"{name}_category"] = value
Is there anyway to achieve this is in a more native vector "datatable
" way.