human
Pandas: Fill missing values by mean in each group faster than transfrom
assistant
Here is some code to replace NaN values in  column 'value' with the mean of data in column 'group' of dataframe `df`

df[['value']].fillna(df.groupby('group').transform('mean'))

#Warning: this code generation is experimental. Please inspect the code for any bugs before executing.