I have a dataframe like below which I need to calculate the weight average. In excel, if I use sumproduct function, I will get a result of 15.25. However, when I use the following code, it gives me 0. How to correct this in the code?

import pandas as pd
df1 = { 'product1':['N/A'],
'product2':[15.25],
'p1 weight':[0],
'p2 weight':[4]}
df1=pd.DataFrame(df1)
df1.fillna(0,inplace=True)
cols_left = [c for c in df1.columns if 'product' in c]
cols_right = [c for c in df1.columns if 'weight' in c]
result = (df1[cols_left] * df1[cols_right]).sum(axis=1) / df1[cols_right].sum(axis=1)
df1['result'] = result
results as below
Be noted, I have to use the cols_left and cols_right approach, because in my real work situation, I have +100 columns which need to be performed the weight average calculation based on the corresponding columns.
Instead of doing hard coding like df1['result1'] = (df1['product1'] * df1['p1 weight'] + df1['product2'] * df1['p2 weight'] )/ df1['p1 weight'] + df1['p2 weight'] and so on, I group all the corresponding columns in the cols_left and cols_right respectively before the sum product calculation.
Any advice are greatly appreciated.
