Need help when working with the Pandas DataFrame object.
Task:
There is a data set, it is necessary for objects, where the value in the column = 1 , replace in the other column the same row with NaN by -1 .
Explanation
heduc column - the duration of education by the husband (if the husband is not NaN , must be replaced by -1 ) the column newermarr - whether the person is married (if 1 not newermarr ) is necessary for everyone outside the marriage, the period of education for the husband is -1 .
Here is an attempt to solve, I can not understand how to leave existing values in else
data_woman['heduc'] = data_woman['nevermarr'].apply(lambda x : -1 if x == 1 else x)