pandas equivalent of np.where
Try: (df[‘A’] + df[‘B’]).where((df[‘A’] < 0) | (df[‘B’] > 0), df[‘A’] / df[‘B’]) The difference between the numpy where and DataFrame where is that the default values are supplied by the DataFrame that the where method is being called on (docs). I.e. np.where(m, A, B) is roughly equivalent to A.where(m, B) If you wanted a … Read more