I would like to replace NaN values in Target with the corresponding Node value. My data is:
Node Target Color node1 node7 Red node1 node9 Red node3 node5 Green node1 node3 Red node3 node1 Red node5 NaN Yellow I would need to have:
Node Target Color node1 node7 Red node1 node9 Red node3 node5 Green node1 node3 Red node3 node1 Red node5 node5 Yellow # here the replacement I think that a possible solution could be using an if statement to check if a node has Target equal to NaN: if yes, then it would be possible to assign itself as target.
df["Target"] = df["Target"].fillna(df["Node"])