I have a dataframe df in pandas with the next data structure:
+------+------+
| col1 | col2 |
+------+------+
| 2 | 1 |
+------+------+
| nan | 3 |
+------+------+
| nan | nan |
+------+------+
There are some values for columns col1 and col2 that are nan, and the others are Integers. What I would like to do is to add a new column col3 to my df dataframe where the values of the other columns are considered.
In this case, if col1 and col2 values for a row are integer values, the new value of col3 would be 0. If col1 is nan and col2 is not nan, col3 would have 1 value. And finally, if both col1 and col2 are nan, col3 would have 2 value.
How can I do it?