Reputation: 508
I was expecting the following line of code to copy values from col4 and col5 (for rows that satisfy the filter) to col1 and col2 of the same rows. However, col1 and col2 remain unchanged.
df[['col1', 'col2']][df['col3'].isnull()] = df[df['col3'].isnull()][['col4', 'col5']]
Upvotes: 0
Views: 37
Reputation: 36545
Only use the mask on the RHS:
df[['col1', 'col2']] = df[df['col3'].isnull()][['col4', 'col5']]
Upvotes: 1