Skip to content

Commit 8f799db

Browse files
committed
BUG: add test to check that no error is raised with empty df & cond
1 parent 87a270a commit 8f799db

File tree

1 file changed

+7
-0
lines changed

1 file changed

+7
-0
lines changed

pandas/tests/frame/test_indexing.py

+7
Original file line numberDiff line numberDiff line change
@@ -2939,6 +2939,13 @@ def test_where_callable(self):
29392939
tm.assert_frame_equal(result,
29402940
(df + 2).where((df + 2) > 8, (df + 2) + 10))
29412941

2942+
def test_where_on_empty_dataframe_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+
df.where(cond) # Should not raise ValueError: Boolean array expected for the condition, not object
2948+
29422949
def test_where_tz_values(self, tz_naive_fixture):
29432950
df1 = DataFrame(DatetimeIndex(['20150101', '20150102', '20150103'],
29442951
tz=tz_naive_fixture),

0 commit comments

Comments
 (0)