@@ -9698,20 +9698,10 @@ def _where(
96989698 if axis is not None :
96999699 axis = self ._get_axis_number (axis )
97009700
9701- cond = common .apply_if_callable (cond , self )
9702-
9703- # We should not be filling NA. See GH#60729
9704- if isinstance (cond , np .ndarray ):
9705- cond = np .array (cond )
9706- cond [isna (cond )] = True
9707- elif isinstance (cond , NDFrame ):
9708- cond = cond .fillna (True )
9709- elif isinstance (cond , (list , tuple )):
9710- cond = np .array (cond )
9711- cond [isna (cond )] = True
9712-
97139701 # align the cond to same shape as myself
9702+ cond = common .apply_if_callable (cond , self )
97149703 if isinstance (cond , NDFrame ):
9704+ cond = cond .fillna (True )
97159705 # CoW: Make sure reference is not kept alive
97169706 if cond .ndim == 1 and self .ndim == 2 :
97179707 cond = cond ._constructor_expanddim (
@@ -9723,6 +9713,7 @@ def _where(
97239713 else :
97249714 if not hasattr (cond , "shape" ):
97259715 cond = np .asanyarray (cond )
9716+ cond [isna (cond )] = True
97269717 if cond .shape != self .shape :
97279718 raise ValueError ("Array conditional must be same shape as self" )
97289719 cond = self ._constructor (cond , ** self ._construct_axes_dict (), copy = False )
0 commit comments