2424 is_numeric_dtype ,
2525 is_integer ,
2626 is_int_or_datetime_dtype ,
27+ is_datetimelike ,
2728 is_dtype_equal ,
2829 is_bool ,
2930 is_list_like ,
@@ -877,7 +878,7 @@ def _get_merge_keys(self):
877878 return left_keys , right_keys , join_names
878879
879880 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
881882 # coerce these if they are originally incompatible types
882883 #
883884 # for example if these are categorical, but are not dtype_equal
@@ -894,6 +895,13 @@ def _maybe_coerce_merge_keys(self):
894895 if is_categorical_dtype (lk ) and is_categorical_dtype (rk ):
895896 if lk .is_dtype_equal (rk ):
896897 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+
897905 elif is_categorical_dtype (lk ) or is_categorical_dtype (rk ):
898906 pass
899907
@@ -904,7 +912,7 @@ def _maybe_coerce_merge_keys(self):
904912 # kinds to proceed, eg. int64 and int8
905913 # further if we are object, but we infer to
906914 # 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 ):
908916 if lk .dtype .kind == rk .dtype .kind :
909917 continue
910918
0 commit comments