pandas use map lambda to fillna python 1

pandas use map lambda to fillna python

import numpy as np

df1['user_score'] = np.where(df1['user_score'].isna(), df2['user_score'], df1['user_score'])

Here is what the above code is Doing:
1. Create a new column in df1 called ‘user_score’
2. If the value in the ‘user_score’ column in df1 is NaN, then use the value in the ‘user_score’ column in df2
3. If the value in the ‘user_score’ column in df1 is not NaN, then use the value in the ‘user_score’ column in df1

Similar Posts