File tree Expand file tree Collapse file tree 1 file changed +6
-7
lines changed Expand file tree Collapse file tree 1 file changed +6
-7
lines changed Original file line number Diff line number Diff line change 28
28
29
29
from pandas .core .dtypes .cast import (
30
30
can_hold_element ,
31
+ find_common_type ,
31
32
maybe_promote ,
32
33
)
33
34
from pandas .core .dtypes .common import (
@@ -1095,14 +1096,12 @@ def _getitem_lowerdim(self, tup: tuple):
1095
1096
return section
1096
1097
# This is an elided recursive call to iloc/loc
1097
1098
out = getattr (section , self .name )[new_key ]
1098
- # Re-interpret dtype of out.values for loc/iloc[int, list/slice ].
1099
+ # Re-interpret dtype of out.values for loc/iloc[int, list-like ].
1099
1100
# GH60600
1100
- if (
1101
- i == 0
1102
- and isinstance (key , int )
1103
- and isinstance (new_key , (list , slice ))
1104
- ):
1105
- out = out .infer_objects ()
1101
+ if i == 0 and isinstance (key , int ) and is_list_like (tup [1 ]):
1102
+ dt = self .obj .dtypes .__getitem__ (tup [1 ])
1103
+ if len (dt ) > 0 :
1104
+ out = out .astype (find_common_type (dt .tolist ()))
1106
1105
return out
1107
1106
1108
1107
raise IndexingError ("not applicable" )
You can’t perform that action at this time.
0 commit comments