I have a dataframe as below:
df = pd.DataFrame({'ORDER':["A", "A", "A", "B", "B","B"], 'New1': [2, 1, 3, 4, np.nan, np.nan], 'New2': [np.nan, np.nan, np.nan, np.nan, 5, np.nan]})
df
ORDER New1 New2
0 A 2.0 NaN
1 A 1.0 NaN
2 A 3.0 NaN
3 B 4.0 NaN
4 B NaN 5.0
5 B NaN NaN
I want to create a column "New" by merging the columns New1 and New2 in a way that if one of the columns is NaN and another one has the value, keep the value. Foe example New for row1 will be 2.
My expected output
ORDER New
0 A 2.0
1 A 1.0
2 A 3.0
3 B 4.0
4 B 5.0
5 B NaN