How to multiply two pandas DataFrame columns in Python

Multiplying two pandas DataFrame columns results in a new column containing the product of the two columns elementwise. For example, multiplying the columns [1, 2, 3] and [4, 5, 6] results in [4, 10, 18].

Solution for How to multiply two pandas DataFrame columns in Python : You can use DataFrame indexing to multiply two columns Use the syntax df[col1] * df[col2] to multiply columns with names col1 and col2 in df. Use DataFrame indexing to assign the result to a new column.


how-to-multiply-two-pandas-dataframe-columns-in-python