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:
1670
1670
lk = extract_array (lk , extract_numpy = True )
1671
1671
rk = extract_array (rk , extract_numpy = True )
1672
1672
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
+
1673
1684
lk_is_cat = isinstance (lk .dtype , CategoricalDtype )
1674
1685
rk_is_cat = isinstance (rk .dtype , CategoricalDtype )
1675
1686
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