@@ -1079,10 +1079,10 @@ def _maybe_coerce_merge_keys(self):
1079
1079
if (len (lk ) and not len (rk )) or (not len (lk ) and len (rk )):
1080
1080
continue
1081
1081
1082
- lk_is_cat = is_categorical_dtype (lk )
1083
- rk_is_cat = is_categorical_dtype (rk )
1084
- lk_is_object = is_object_dtype (lk )
1085
- rk_is_object = is_object_dtype (rk )
1082
+ lk_is_cat = is_categorical_dtype (lk . dtype )
1083
+ rk_is_cat = is_categorical_dtype (rk . dtype )
1084
+ lk_is_object = is_object_dtype (lk . dtype )
1085
+ rk_is_object = is_object_dtype (rk . dtype )
1086
1086
1087
1087
# if either left or right is a categorical
1088
1088
# then the must match exactly in categories & ordered
@@ -1105,12 +1105,12 @@ def _maybe_coerce_merge_keys(self):
1105
1105
# kinds to proceed, eg. int64 and int8, int and float
1106
1106
# further if we are object, but we infer to
1107
1107
# the same, then proceed
1108
- if is_numeric_dtype (lk ) and is_numeric_dtype (rk ):
1108
+ if is_numeric_dtype (lk . dtype ) and is_numeric_dtype (rk . dtype ):
1109
1109
if lk .dtype .kind == rk .dtype .kind :
1110
1110
continue
1111
1111
1112
1112
# check whether ints and floats
1113
- elif is_integer_dtype (rk ) and is_float_dtype (lk ):
1113
+ elif is_integer_dtype (rk . dtype ) and is_float_dtype (lk . dtype ):
1114
1114
if not (lk == lk .astype (rk .dtype ))[~ np .isnan (lk )].all ():
1115
1115
warnings .warn (
1116
1116
"You are merging on int and float "
@@ -1120,7 +1120,7 @@ def _maybe_coerce_merge_keys(self):
1120
1120
)
1121
1121
continue
1122
1122
1123
- elif is_float_dtype (rk ) and is_integer_dtype (lk ):
1123
+ elif is_float_dtype (rk . dtype ) and is_integer_dtype (lk . dtype ):
1124
1124
if not (rk == rk .astype (lk .dtype ))[~ np .isnan (rk )].all ():
1125
1125
warnings .warn (
1126
1126
"You are merging on int and float "
@@ -1140,14 +1140,14 @@ def _maybe_coerce_merge_keys(self):
1140
1140
# incompatible dtypes GH 9780, GH 15800
1141
1141
1142
1142
# bool values are coerced to object
1143
- elif (lk_is_object and is_bool_dtype (rk )) or (
1144
- is_bool_dtype (lk ) and rk_is_object
1143
+ elif (lk_is_object and is_bool_dtype (rk . dtype )) or (
1144
+ is_bool_dtype (lk . dtype ) and rk_is_object
1145
1145
):
1146
1146
pass
1147
1147
1148
1148
# object values are allowed to be merged
1149
- elif (lk_is_object and is_numeric_dtype (rk )) or (
1150
- is_numeric_dtype (lk ) and rk_is_object
1149
+ elif (lk_is_object and is_numeric_dtype (rk . dtype )) or (
1150
+ is_numeric_dtype (lk . dtype ) and rk_is_object
1151
1151
):
1152
1152
inferred_left = lib .infer_dtype (lk , skipna = False )
1153
1153
inferred_right = lib .infer_dtype (rk , skipna = False )
@@ -1167,13 +1167,17 @@ def _maybe_coerce_merge_keys(self):
1167
1167
raise ValueError (msg )
1168
1168
1169
1169
# datetimelikes must match exactly
1170
- elif needs_i8_conversion (lk ) and not needs_i8_conversion (rk ):
1170
+ elif needs_i8_conversion (lk . dtype ) and not needs_i8_conversion (rk . dtype ):
1171
1171
raise ValueError (msg )
1172
- elif not needs_i8_conversion (lk ) and needs_i8_conversion (rk ):
1172
+ elif not needs_i8_conversion (lk . dtype ) and needs_i8_conversion (rk . dtype ):
1173
1173
raise ValueError (msg )
1174
- elif is_datetime64tz_dtype (lk ) and not is_datetime64tz_dtype (rk ):
1174
+ elif is_datetime64tz_dtype (lk .dtype ) and not is_datetime64tz_dtype (
1175
+ rk .dtype
1176
+ ):
1175
1177
raise ValueError (msg )
1176
- elif not is_datetime64tz_dtype (lk ) and is_datetime64tz_dtype (rk ):
1178
+ elif not is_datetime64tz_dtype (lk .dtype ) and is_datetime64tz_dtype (
1179
+ rk .dtype
1180
+ ):
1177
1181
raise ValueError (msg )
1178
1182
1179
1183
elif lk_is_object and rk_is_object :
0 commit comments