Issue
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
Solution
You missing the 2nd condition and function name should be isna
areas['area3'] = np.where(areas['area1'].isna(), areas['area2'], areas['area1'])
Answered By - BENY
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.