Skip to content

Commit 92ccd06

Browse files
committed
BUG: add a whatsnew entry in v0.24.0 / bug fixes / reshaping
Also - move test close to test_where_none` - reformat test as asked in PR
1 parent 319f1e2 commit 92ccd06

File tree

2 files changed

+11
-10
lines changed

2 files changed

+11
-10
lines changed

doc/source/whatsnew/v0.24.0.txt

+1-1
Original file line numberDiff line numberDiff line change
@@ -487,7 +487,7 @@ Reshaping
487487
- Bug in :func:`pandas.concat` when joining resampled DataFrames with timezone aware index (:issue:`13783`)
488488
- Bug in :meth:`Series.combine_first` with ``datetime64[ns, tz]`` dtype which would return tz-naive result (:issue:`21469`)
489489
- Bug in :meth:`Series.where` and :meth:`DataFrame.where` with ``datetime64[ns, tz]`` dtype (:issue:`21546`)
490-
-
490+
- Bug in :meht:`Dataframe.where` with empty ``df`` and empty ``cond`` having non bool dtype (:pr:`21947`)
491491
-
492492

493493
Build Changes

pandas/tests/frame/test_indexing.py

+10-9
Original file line numberDiff line numberDiff line change
@@ -2773,6 +2773,16 @@ def test_where_none(self):
27732773
'on mixed-type'):
27742774
df.where(~isna(df), None, inplace=True)
27752775

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+
27762786
def test_where_align(self):
27772787

27782788
def create():
@@ -2939,15 +2949,6 @@ def test_where_callable(self):
29392949
tm.assert_frame_equal(result,
29402950
(df + 2).where((df + 2) > 8, (df + 2) + 10))
29412951

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-
29512952
def test_where_tz_values(self, tz_naive_fixture):
29522953
df1 = DataFrame(DatetimeIndex(['20150101', '20150102', '20150103'],
29532954
tz=tz_naive_fixture),

0 commit comments

Comments
 (0)