Skip to content

Commit

Permalink
BUG: add a whatsnew entry in v0.24.0 / bug fixes / reshaping
Browse files Browse the repository at this point in the history
Also
- move test close to test_where_none`
- reformat test as asked in PR
  • Loading branch information
pajachiet committed Aug 9, 2018
1 parent 319f1e2 commit 92ccd06
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 10 deletions.
2 changes: 1 addition & 1 deletion doc/source/whatsnew/v0.24.0.txt
Original file line number Diff line number Diff line change
Expand Up @@ -487,7 +487,7 @@ Reshaping
- Bug in :func:`pandas.concat` when joining resampled DataFrames with timezone aware index (:issue:`13783`)
- Bug in :meth:`Series.combine_first` with ``datetime64[ns, tz]`` dtype which would return tz-naive result (:issue:`21469`)
- Bug in :meth:`Series.where` and :meth:`DataFrame.where` with ``datetime64[ns, tz]`` dtype (:issue:`21546`)
-
- Bug in :meht:`Dataframe.where` with empty ``df`` and empty ``cond`` having non bool dtype (:pr:`21947`)
-

Build Changes
Expand Down
19 changes: 10 additions & 9 deletions pandas/tests/frame/test_indexing.py
Original file line number Diff line number Diff line change
Expand Up @@ -2773,6 +2773,16 @@ def test_where_none(self):
'on mixed-type'):
df.where(~isna(df), None, inplace=True)

def test_where_empty_df_and_empty_cond_having_non_bool_dtypes(self):
# GH 21947
df = pd.DataFrame(columns=['a'])
cond = df.applymap(lambda x: x > 0)
# Should not raise ValueError:
# Boolean array expected for the condition, not object
result = df.where(cond)
expected = df
tm.assert_frame_equal(expected, result)

def test_where_align(self):

def create():
Expand Down Expand Up @@ -2939,15 +2949,6 @@ def test_where_callable(self):
tm.assert_frame_equal(result,
(df + 2).where((df + 2) > 8, (df + 2) + 10))

def test_where_empty_df_and_empty_cond_having_non_bool_dtypes(self):
# GH 21947
data = []
df = pd.DataFrame(columns=['a'], data=data)
cond = df.applymap(lambda x: x > 0)
# Should not raise ValueError:
# Boolean array expected for the condition, not object
df.where(cond)

def test_where_tz_values(self, tz_naive_fixture):
df1 = DataFrame(DatetimeIndex(['20150101', '20150102', '20150103'],
tz=tz_naive_fixture),
Expand Down

0 comments on commit 92ccd06

Please sign in to comment.