'Filter a float dataframe with a boolean dataframe keeping the NaNs for the non-matching rows

I have the following two data frames:

bar_data = pd.DataFrame({'high': [156.51, 157.28, 157.1, 155.01, 154.3], 'low': [155.83, 155.65, 154.94, 154.05, 154.1]})

     high     low
0  156.51  155.83
1  157.28  155.65
2  157.10  154.94
3  155.01  154.05
4  154.30  154.10

signal = pd.Series([0, 1, 0, 1, 0], dtype=pd.Int64Dtype).astype(bool)

0    False
1     True
2    False
3     True
4    False
dtype: bool

I would like to get all 5 rows in the result. The rows matching with True should return the 'low' value. The rows not matching should return NaN.

0    NaN     
1    155.65
2    NaN
3    154.05
4    NaN


Sources

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

Source: Stack Overflow

Solution Source