@@ -9698,20 +9698,10 @@ def _where(
9698
9698
if axis is not None :
9699
9699
axis = self ._get_axis_number (axis )
9700
9700
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
-
9713
9701
# align the cond to same shape as myself
9702
+ cond = common .apply_if_callable (cond , self )
9714
9703
if isinstance (cond , NDFrame ):
9704
+ cond = cond .fillna (True )
9715
9705
# CoW: Make sure reference is not kept alive
9716
9706
if cond .ndim == 1 and self .ndim == 2 :
9717
9707
cond = cond ._constructor_expanddim (
@@ -9723,6 +9713,7 @@ def _where(
9723
9713
else :
9724
9714
if not hasattr (cond , "shape" ):
9725
9715
cond = np .asanyarray (cond )
9716
+ cond [isna (cond )] = True
9726
9717
if cond .shape != self .shape :
9727
9718
raise ValueError ("Array conditional must be same shape as self" )
9728
9719
cond = self ._constructor (cond , ** self ._construct_axes_dict (), copy = False )
0 commit comments