I have a pandas dataframe that looks like this:
+-----+--------+-------+
| Age | PhysID | PedID |
+-----+--------+-------+
| 28 | 111 | 123 |
| 26 | 111 | 123 |
| 3 | 111 | 123 |
+-----+--------+-------+
I would like to create a new column called DocID
which has a value equal to PhysID
if Age>18
or equal to PedID
otherwise. The output would look like this:
+-----+--------+-------+-------+
| Age | PhysID | PedID | DocID |
+-----+--------+-------+-------+
| 28 | 111 | 123 | 111 |
| 26 | 111 | 123 | 111 |
| 3 | 111 | 123 | 123 |
+-----+--------+-------+-------+
Is there a clean way of doing this using some inbuilt functions instead of writing my own? Thanks!