Skip to content

Commit 64e88e3

Browse files
authored
Add np.intc to _factorizers in pd.merge (#53175)
* Add np.intc to merge table * Add whatsnew * Updated unit test * Fix lint * Only add intc to _factorizers if not int32 * Mention that the problem is on Windows * Update pandas/core/reshape/merge.py
1 parent c280178 commit 64e88e3

File tree

3 files changed

+8
-2
lines changed

3 files changed

+8
-2
lines changed

doc/source/whatsnew/v2.0.2.rst

+1-1
Original file line numberDiff line numberDiff line change
@@ -14,11 +14,11 @@ including other versions of pandas.
1414
Fixed regressions
1515
~~~~~~~~~~~~~~~~~
1616
- Fixed performance regression in :meth:`GroupBy.apply` (:issue:`53195`)
17+
- Fixed regression in :func:`merge` on Windows when dtype is ``np.intc`` (:issue:`52451`)
1718
- Fixed regression in :func:`read_sql` dropping columns with duplicated column names (:issue:`53117`)
1819
- Fixed regression in :meth:`DataFrame.loc` losing :class:`MultiIndex` name when enlarging object (:issue:`53053`)
1920
- Fixed regression in :meth:`DataFrame.to_string` printing a backslash at the end of the first row of data, instead of headers, when the DataFrame doesn't fit the line width (:issue:`53054`)
2021
- Fixed regression in :meth:`MultiIndex.join` returning levels in wrong order (:issue:`53093`)
21-
-
2222

2323
.. ---------------------------------------------------------------------------
2424
.. _whatsnew_202.bug_fixes:

pandas/core/reshape/merge.py

+4
Original file line numberDiff line numberDiff line change
@@ -123,6 +123,10 @@
123123
np.object_: libhashtable.ObjectFactorizer,
124124
}
125125

126+
# See https://github.com/pandas-dev/pandas/issues/52451
127+
if np.intc is not np.int32:
128+
_factorizers[np.intc] = libhashtable.Int64Factorizer
129+
126130
_known = (np.ndarray, ExtensionArray, Index, ABCSeries)
127131

128132

pandas/tests/reshape/merge/test_merge.py

+3-1
Original file line numberDiff line numberDiff line change
@@ -1460,7 +1460,9 @@ def test_different(self, right_vals):
14601460
result = merge(left, right, on="A")
14611461
assert is_object_dtype(result.A.dtype)
14621462

1463-
@pytest.mark.parametrize("d1", [np.int64, np.int32, np.int16, np.int8, np.uint8])
1463+
@pytest.mark.parametrize(
1464+
"d1", [np.int64, np.int32, np.intc, np.int16, np.int8, np.uint8]
1465+
)
14641466
@pytest.mark.parametrize("d2", [np.int64, np.float64, np.float32, np.float16])
14651467
def test_join_multi_dtypes(self, d1, d2):
14661468
dtype1 = np.dtype(d1)

0 commit comments

Comments
 (0)