Skip to content
Advertisement

Pandas: Replace value in column by using another column, if condition is true

I have the following dataframe:

JavaScript

I would like to replace value in column Sector_y by using column Sector_x, if Sector_y = ”

so that I get the following result:

JavaScript

I tried using the code

JavaScript

but didn’t deliver the result I wanted.

Any suggestions how to solve the problem?

Advertisement

Answer

Fix np.where

JavaScript
User contributions licensed under: CC BY-SA
3 People found this is helpful
Advertisement