I want to multiply a list of columns with one col so I have list of the columns = cols and I want to multiply them with the columns "multi"
data={"col1":[2,3,4,5],
"col2":[4,2,4,6],
"col3":[7,6,9,11],
"col4":[14,11,22,8],
"multi":[1.4,2.5,1.6,2.2]}
df=pd.DataFrame.from_dict(data)
cols=list(df.columns)
cols.remove("multi")
df
So I try to do this:
df[cols]=df[cols]*df["multi"]
But I get
ValueError: Columns must be same length as key