24
24
is_numeric_dtype ,
25
25
is_integer ,
26
26
is_int_or_datetime_dtype ,
27
+ is_datetimelike ,
27
28
is_dtype_equal ,
28
29
is_bool ,
29
30
is_list_like ,
@@ -877,7 +878,7 @@ def _get_merge_keys(self):
877
878
return left_keys , right_keys , join_names
878
879
879
880
def _maybe_coerce_merge_keys (self ):
880
- # we have valid mergee's but we may have to further
881
+ # we have valid mergees but we may have to further
881
882
# coerce these if they are originally incompatible types
882
883
#
883
884
# for example if these are categorical, but are not dtype_equal
@@ -894,6 +895,13 @@ def _maybe_coerce_merge_keys(self):
894
895
if is_categorical_dtype (lk ) and is_categorical_dtype (rk ):
895
896
if lk .is_dtype_equal (rk ):
896
897
continue
898
+
899
+ # if we are dates with differing categories
900
+ # then allow them to proceed because
901
+ # coercing to object below results in integers.
902
+ if is_datetimelike (lk .categories ) and is_datetimelike (rk .categories ):
903
+ continue
904
+
897
905
elif is_categorical_dtype (lk ) or is_categorical_dtype (rk ):
898
906
pass
899
907
@@ -904,7 +912,7 @@ def _maybe_coerce_merge_keys(self):
904
912
# kinds to proceed, eg. int64 and int8
905
913
# further if we are object, but we infer to
906
914
# the same, then proceed
907
- if ( is_numeric_dtype (lk ) and is_numeric_dtype (rk ) ):
915
+ if is_numeric_dtype (lk ) and is_numeric_dtype (rk ):
908
916
if lk .dtype .kind == rk .dtype .kind :
909
917
continue
910
918
0 commit comments