Have 2 dataframes df['x'] and df['y']. How do i multiply the 2 tables and sum the rows?
x0 x1 x2 y0 y1 y2
2 5 9 2 3 4
Nan 4 7 2 2 3
3 Nan 3 1 2 3
Desired output:
(2x2)+(5x3)+(9x4) = 55
etc..
Nan should be treated as 0.
I keep hitting results with nan values with the below code.
Any other more efficient ways to solve this?
df['z'] = (df['x'].to_numpy() * df['y'].to_numpy()).sum(axis=1)