I have a dataframe like this
df = (pd.DataFrame({'ID': ['ID1', 'ID2', 'ID3'],
'colA': ['A', 'B', 'C'],
'colB': ['D', np.nan, 'E']}))
df
ID colA colB
0 ID1 A D
1 ID2 B NaN
2 ID3 C E
I want to combine the two columns, however keep only column A if column B is NaN. Hence Expected output is
ID colA colB colC
0 ID1 A D A_D
1 ID2 B NaN B
2 ID3 C E C_E