xxxxxxxxxx
subset = df.columns.difference(['target'])
df.loc[:, subset] = df.loc[:, subset].fillna(-1)
xxxxxxxxxx
# if you want to fill NaN in a single column with its mean value
df['col'].fillna(df['col'].mean(), inplace=True)
# if you want to fill NaN in more than one columns with their respective mean values
df.fillna(df.mean(), inplace=True)
xxxxxxxxxx
# based on another column value
df['column_1'].fillna(df['column_2'], inplace=True)
xxxxxxxxxx
# selecting your desired columns
df[['a', 'b']] = df[['a', 'b']].fillna(df['c'], inplace=True)