let's say the dataframe has 300 columns, :
col1 col2 col3.... col300
A 2 5 50
A NaN NaN 32
B 5 4 NaN
I want to fill in the blanks with means of corresponding groups in col1, but I want to keep col4 and col5 unchanged and actually want to keep the Nan values in those columns.
I am using the following code to fill the NaN values for the entire dataframe
df.groupby("col1").transform(lambda x: x.fillna(x.mean()))
what can I do to add the col4-col5 as exceptions?