I have an example dataframe:
columns = ["Value A_Input", "Value B_Input", "Value C_Input", "Column A", "Column B"]
raw_data = [
["aaa", "ddd", "ggg", "Value A", "aaa"],
["bbb", "eee", "hhh", "Value C", "hhh"],
["ccc", "fff", "iii", "Value B", "fff"],
]
df = pd.DataFrame(raw_data, columns=columns)
I want to set the value of Column B based on the value in the column name that corresponds to Column A value + string “_Input”. For example, Column A first row reads “Value A”, so look for Value A_Input column and find “aaa”. Any hint on how to do this? Thank you
Tried the following but it doesn’t work
df['Column B'] = df[str([x for x in df['Column A']]).split('_')[0]+'_Input')]