I'm doing comparisons (equality) of some series which have some NaN elements and numeric elements. I'd like every comparison involving a NaN to return NaN instead of False - what's the best Numpy function to do this?
df = pd.DataFrame({'a': [np.NaN, np.NaN, 1], 'b': [np.NaN, 1, 1]})
df['a'] == df['b']
gives
0 False
1 False
2 True
dtype: bool
when I'd like it to return
0 NaN
1 NaN
2 1
dtype: float
or
0 NaN
1 NaN
2 True
dtype: bool