Search code examples
pythonpandasdataframenanmultiplication

After multiplying two column i am getting nan values


I am not expecing nan value; how I can solve this error?

UNITS = {"KG/HA":1, "L/HA":1, "G/HA":0.001, "ML/100KG":0.001, "G/L":0.001}
i = df["DOSAGE"]
u = df["DOSAGE_UNIT"]
df['NEW'] = i.map(UNITS) * u
#print(df.head())
df = df['NEW']
print(df)
df = pd.DataFrame(df)

Output:

0        NaN
1        NaN
3        NaN
4        NaN
6        NaN
        ... 
24287    NaN
24288    NaN
24289    NaN
24290    NaN
24291    NaN
Name: NEW, Length: 19243, dtype: object)

Solution

  • df['NEW']=i * u.map(UNITS) #it works