@@ -2773,6 +2773,16 @@ def test_where_none(self):
2773
2773
'on mixed-type' ):
2774
2774
df .where (~ isna (df ), None , inplace = True )
2775
2775
2776
+ def test_where_empty_df_and_empty_cond_having_non_bool_dtypes (self ):
2777
+ # GH 21947
2778
+ df = pd .DataFrame (columns = ['a' ])
2779
+ cond = df .applymap (lambda x : x > 0 )
2780
+ # Should not raise ValueError:
2781
+ # Boolean array expected for the condition, not object
2782
+ result = df .where (cond )
2783
+ expected = df
2784
+ tm .assert_frame_equal (expected , result )
2785
+
2776
2786
def test_where_align (self ):
2777
2787
2778
2788
def create ():
@@ -2939,15 +2949,6 @@ def test_where_callable(self):
2939
2949
tm .assert_frame_equal (result ,
2940
2950
(df + 2 ).where ((df + 2 ) > 8 , (df + 2 ) + 10 ))
2941
2951
2942
- def test_where_empty_df_and_empty_cond_having_non_bool_dtypes (self ):
2943
- # GH 21947
2944
- data = []
2945
- df = pd .DataFrame (columns = ['a' ], data = data )
2946
- cond = df .applymap (lambda x : x > 0 )
2947
- # Should not raise ValueError:
2948
- # Boolean array expected for the condition, not object
2949
- df .where (cond )
2950
-
2951
2952
def test_where_tz_values (self , tz_naive_fixture ):
2952
2953
df1 = DataFrame (DatetimeIndex (['20150101' , '20150102' , '20150103' ],
2953
2954
tz = tz_naive_fixture ),
0 commit comments