File tree 1 file changed +16
-0
lines changed
pandas/tests/frame/indexing
1 file changed +16
-0
lines changed Original file line number Diff line number Diff line change 12
12
from pandas import (
13
13
DataFrame ,
14
14
DatetimeIndex ,
15
+ Index ,
15
16
Series ,
16
17
StringDtype ,
17
18
Timestamp ,
@@ -863,6 +864,21 @@ def test_where_none_nan_coerce():
863
864
tm .assert_frame_equal (result , expected )
864
865
865
866
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
+
866
882
def test_where_non_keyword_deprecation (frame_or_series ):
867
883
# GH 41485
868
884
obj = frame_or_series (range (5 ))
You can’t perform that action at this time.
0 commit comments