I have a DataFrame (df
), with the following columns:
cols = ['A','B','C','D']
How can I multiply the values in these columns to form a single column called 'VAL'?
I can do this: df['VAL'] = df['A']*df['B']*df['C']*df['D']
But this will not scale; I want to use the cols
variable to multiply these columns together.