52
52
ensure_float64 ,
53
53
ensure_int64 ,
54
54
ensure_object ,
55
- is_array_like ,
56
55
is_bool ,
57
56
is_bool_dtype ,
58
57
is_extension_array_dtype ,
124
123
np .object_ : libhashtable .ObjectFactorizer ,
125
124
}
126
125
126
+ _known = (np .ndarray , ExtensionArray , Index , ABCSeries )
127
+
127
128
128
129
@Substitution ("\n left : DataFrame or named Series" )
129
130
@Appender (_merge_doc , indents = 0 )
@@ -928,7 +929,7 @@ def _maybe_add_join_keys(
928
929
left_has_missing = None
929
930
right_has_missing = None
930
931
931
- assert all (is_array_like ( x ) for x in self .left_join_keys )
932
+ assert all (isinstance ( x , _known ) for x in self .left_join_keys )
932
933
933
934
keys = zip (self .join_names , self .left_on , self .right_on )
934
935
for i , (name , lname , rname ) in enumerate (keys ):
@@ -1141,8 +1142,8 @@ def _get_merge_keys(
1141
1142
1142
1143
left , right = self .left , self .right
1143
1144
1144
- is_lkey = lambda x : is_array_like ( x ) and len (x ) == len (left )
1145
- is_rkey = lambda x : is_array_like ( x ) and len (x ) == len (right )
1145
+ is_lkey = lambda x : isinstance ( x , _known ) and len (x ) == len (left )
1146
+ is_rkey = lambda x : isinstance ( x , _known ) and len (x ) == len (right )
1146
1147
1147
1148
# Note that pd.merge_asof() has separate 'on' and 'by' parameters. A
1148
1149
# user could, for example, request 'left_index' and 'left_by'. In a
@@ -1914,7 +1915,7 @@ def _validate_left_right_on(self, left_on, right_on):
1914
1915
# GH#29130 Check that merge keys do not have dtype object
1915
1916
if not self .left_index :
1916
1917
left_on_0 = left_on [0 ]
1917
- if is_array_like (left_on_0 ):
1918
+ if isinstance (left_on_0 , _known ):
1918
1919
lo_dtype = left_on_0 .dtype
1919
1920
else :
1920
1921
lo_dtype = (
@@ -1927,7 +1928,7 @@ def _validate_left_right_on(self, left_on, right_on):
1927
1928
1928
1929
if not self .right_index :
1929
1930
right_on_0 = right_on [0 ]
1930
- if is_array_like (right_on_0 ):
1931
+ if isinstance (right_on_0 , _known ):
1931
1932
ro_dtype = right_on_0 .dtype
1932
1933
else :
1933
1934
ro_dtype = (
0 commit comments