I tried different solutions refering to this problem but nothing worked. I have 3 columns of type float and I want to compare the moltiplication of those with another column row by row. Original dataframe looks like this:
+------+------+------+--------+
| Col1 | Col2 | Col3 | Result |
+------+------+------+--------+
| 4.5 | 2.0 | 2.0 | 18.0 |
| 2.3 | 1.0 | 3.5 | 8.05 |
| 2.5 | 5.2 | 3.0 | 5.0 |
+------+------+------+--------+
Third row is obviously wrong, first and second rows are right. So I created a new column named Check, which should tell, if column Result is the multiplication of col1,col2 and col3.
df['Check'] = np.where((df.col1*df.col2*df.col3) != falseVol.VOLUM,'Result is wrong', 'Result is right')
Because I got wrong results with this, I tried several ways to multiply columns and created another column to store the calculated results in:
df['calculated'] = df['col1'] * df['col2'] * df['col3']
df['calculated'] = df['col1'].multiply(df['col2'] * df['col3'], axis=0)
Each gives me matching results but the check does not work.
How does row by row mulitplication of several columns and comparing work? Thank you.