'How to conditionally replace values in a pandas dataframe column with values from another column [duplicate]
I know this type of question has been asked many times before. With the answers provided I am not able to move beyond this point.
I have a dataframe named areas. I want have a new column which takes the values from column area1 unless the value is NaN then the value must be taken from area2.
area1 area2
NaN 100
NaN 101
NaN 102
A 103
B 104
C 105
I have tried a bunch of things but am stuck. The last thing I tried was.
areas['area3'] = np.where(areas['area1'].isnan, areas['areas2'])
Help would be very much appreciated
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
