File tree Expand file tree Collapse file tree 1 file changed +11
-0
lines changed Expand file tree Collapse file tree 1 file changed +11
-0
lines changed Original file line number Diff line number Diff line change @@ -1670,6 +1670,17 @@ def _maybe_coerce_merge_keys(self) -> None:
16701670 lk = extract_array (lk , extract_numpy = True )
16711671 rk = extract_array (rk , extract_numpy = True )
16721672
1673+ # Explicitly disallow merging int64 and uint64 (or vice versa)
1674+ if (
1675+ (lk .dtype == np .dtype ("int64" ) and rk .dtype == np .dtype ("uint64" ))
1676+ or (lk .dtype == np .dtype ("uint64" ) and rk .dtype == np .dtype ("int64" ))
1677+ ):
1678+ raise ValueError (
1679+ f"You are trying to merge on int64 and uint64 columns for key '{ name } '. "
1680+ "This is not allowed as it can lead to incorrect results. "
1681+ "Please cast both columns to the same signedness before merging."
1682+ )
1683+
16731684 lk_is_cat = isinstance (lk .dtype , CategoricalDtype )
16741685 rk_is_cat = isinstance (rk .dtype , CategoricalDtype )
16751686 lk_is_object_or_string = is_object_dtype (lk .dtype ) or is_string_dtype (
You can’t perform that action at this time.
0 commit comments