File tree Expand file tree Collapse file tree 1 file changed +16
-0
lines changed
pandas/tests/frame/indexing Expand file tree Collapse file tree 1 file changed +16
-0
lines changed Original file line number Diff line number Diff line change 1212from pandas import (
1313 DataFrame ,
1414 DatetimeIndex ,
15+ Index ,
1516 Series ,
1617 StringDtype ,
1718 Timestamp ,
@@ -863,6 +864,21 @@ def test_where_none_nan_coerce():
863864 tm .assert_frame_equal (result , expected )
864865
865866
867+ def test_where_duplicate_axes_mixed_dtypes ():
868+ # GH 25399, verify manually masking is not affected anymore by dtype of column for
869+ # duplicate axes.
870+ result = DataFrame (data = [[0 , np .nan ]], columns = Index (["A" , "A" ]))
871+ index , columns = result .axes
872+ mask = DataFrame (data = [[True , True ]], columns = columns , index = index )
873+ a = result .astype (object ).where (mask )
874+ b = result .astype ("f8" ).where (mask )
875+ c = result .T .where (mask .T ).T
876+ d = result .where (mask ) # used to fail with "cannot reindex from a duplicate axis"
877+ tm .assert_frame_equal (a .astype ("f8" ), b .astype ("f8" ))
878+ tm .assert_frame_equal (b .astype ("f8" ), c .astype ("f8" ))
879+ tm .assert_frame_equal (c .astype ("f8" ), d .astype ("f8" ))
880+
881+
866882def test_where_non_keyword_deprecation (frame_or_series ):
867883 # GH 41485
868884 obj = frame_or_series (range (5 ))
You can’t perform that action at this time.
0 commit comments