Skip to content

Commit 180536a

Browse files
hoxbromroeschke
authored andcommitted
Backport PR pandas-dev#53175: Add np.intc to _factorizers in pd.merge
1 parent 340346c commit 180536a

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

127131
@Substitution("\nleft : DataFrame or named Series")
128132
@Appender(_merge_doc, indents=0)

pandas/tests/reshape/merge/test_merge.py

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

1467-
@pytest.mark.parametrize("d1", [np.int64, np.int32, np.int16, np.int8, np.uint8])
1467+
@pytest.mark.parametrize(
1468+
"d1", [np.int64, np.int32, np.intc, np.int16, np.int8, np.uint8]
1469+
)
14681470
@pytest.mark.parametrize("d2", [np.int64, np.float64, np.float32, np.float16])
14691471
def test_join_multi_dtypes(self, d1, d2):
14701472
dtype1 = np.dtype(d1)

0 commit comments

Comments
 (0)