I have a data frame with below data:

I want to replace the null values of each country by its respective mean values.
For Eg, I have calculated the mean values with following code:
df2=df.groupby('country').mean()

I have to replace the null values in df with corresponding mean value present in df2. If the mean value is NaN, then keep Nan, else the value.
I have tried with below code but failed : 1.Output still has NaN values:

2.
df['retail'] = df['retail'].replace('',df.groupby('country').mean())

To replace nulls with the mean of the column you should do: