'Create a new column in Pandas Dataframe based on the 'NaN' values in another column

I have a dataframe:

A B
1 NaN
2 3
4 NaN
5 NaN
6 7

I want to create a new column C containing the value from B that aren't NaN, otherwise the values from A. This would be a simple matter in Excel; is it easy in Pandas?



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source