I want to combine two columns of a dataframe depending on their values. The values per row are going to be in one of three states:
A) Either they are both the same value,
B) Only one cell has a value
C) They are different values
For example:
I want to make this into one column depending on their similarity. If they are equal, then it should just be that value. If one is blank then it should be non-NaN value. And if they are not equal to each other then I want to raise a flag (something like "At row N, cell 1 does not match cell 2", not important what it is).
So using the above example, the column would look like:
The "!" is just a placeholder. How could I go about doing this.
This is an example of a similar problem, but I also need the added step of the function considering what the two cell values are. Combine two columns of text in dataframe in pandas/python
Apologies for using Excel screenshots, not sure how to properly create a table here.