Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 16 additions & 0 deletions pandas/tests/frame/indexing/test_where.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
from pandas import (
DataFrame,
DatetimeIndex,
Index,
Series,
StringDtype,
Timestamp,
Expand Down Expand Up @@ -863,6 +864,21 @@ def test_where_none_nan_coerce():
tm.assert_frame_equal(result, expected)


def test_where_duplicate_axes_mixed_dtypes():
# GH 25399, verify manually masking is not affected anymore by dtype of column for
# duplicate axes.
result = DataFrame(data=[[0, np.nan]], columns=Index(["A", "A"]))
index, columns = result.axes
mask = DataFrame(data=[[True, True]], columns=columns, index=index)
a = result.astype(object).where(mask)
b = result.astype("f8").where(mask)
c = result.T.where(mask.T).T
d = result.where(mask) # used to fail with "cannot reindex from a duplicate axis"
tm.assert_frame_equal(a.astype("f8"), b.astype("f8"))
tm.assert_frame_equal(b.astype("f8"), c.astype("f8"))
tm.assert_frame_equal(c.astype("f8"), d.astype("f8"))


def test_where_non_keyword_deprecation(frame_or_series):
# GH 41485
obj = frame_or_series(range(5))
Expand Down