Skip to content
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 11 additions & 1 deletion pandas/core/reshape/merge.py
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,17 @@

# See https://github.com/pandas-dev/pandas/issues/52451
if np.intc is not np.int32:
_factorizers[np.intc] = libhashtable.Int64Factorizer
if np.dtype(np.intc).itemsize == 4:
_factorizers[np.intc] = libhashtable.Int32Factorizer
else:
_factorizers[np.intc] = libhashtable.Int64Factorizer

if np.uintc is not np.uint32:
if np.dtype(np.uintc).itemsize == 4:
_factorizers[np.uintc] = libhashtable.UInt32Factorizer
else:
_factorizers[np.uintc] = libhashtable.UInt64Factorizer


_known = (np.ndarray, ExtensionArray, Index, ABCSeries)

Expand Down
14 changes: 14 additions & 0 deletions pandas/tests/reshape/merge/test_merge.py
Original file line number Diff line number Diff line change
Expand Up @@ -1843,6 +1843,20 @@ def test_merge_empty(self, left_empty, how, exp):

tm.assert_frame_equal(result, expected)

def test_merge_with_uintc_columns(dataframes_with_uintc):
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
def test_merge_with_uintc_columns(dataframes_with_uintc):
def test_merge_with_uintc_columns():

Looks like that fixture wasn't used

"""To test if pd.merge works with numpy.uintc on windows"""

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
"""To test if pd.merge works with numpy.uintc on windows"""

We don't use docstrings in our tests

df1 = pd.DataFrame({"a": ["foo", "bar"], "b": np.array([1, 2], dtype=np.uintc)})
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we have tests with np.intc as well?

df2 = pd.DataFrame({"a": ["foo", "baz"], "b": np.array([3, 4], dtype=np.uintc)})
result = df1.merge(df2, how="outer")
expected = pd.DataFrame(
{
"a": ["bar", "baz", "foo", "foo"],
"b": np.array([2, 4, 1, 3], dtype=np.uintc),
}
)
tm.assert_frame_equal(result.reset_index(drop=True), expected)


@pytest.fixture
def left():
Expand Down
Loading