Skip to content

Commit 9a3a019

Browse files
Added tests for numpy.intc
1 parent 9b023e6 commit 9a3a019

File tree

1 file changed

+27
-3
lines changed

1 file changed

+27
-3
lines changed

pandas/tests/reshape/merge/test_merge.py

Lines changed: 27 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1843,9 +1843,7 @@ def test_merge_empty(self, left_empty, how, exp):
18431843

18441844
tm.assert_frame_equal(result, expected)
18451845

1846-
def test_merge_with_uintc_columns(dataframes_with_uintc):
1847-
"""To test if pd.merge works with numpy.uintc on windows"""
1848-
1846+
def test_merge_with_uintc_columns(self):
18491847
df1 = pd.DataFrame({"a": ["foo", "bar"], "b": np.array([1, 2], dtype=np.uintc)})
18501848
df2 = pd.DataFrame({"a": ["foo", "baz"], "b": np.array([3, 4], dtype=np.uintc)})
18511849
result = df1.merge(df2, how="outer")
@@ -1856,6 +1854,32 @@ def test_merge_with_uintc_columns(dataframes_with_uintc):
18561854
}
18571855
)
18581856
tm.assert_frame_equal(result.reset_index(drop=True), expected)
1857+
1858+
def test_merge_with_intc_columns(self):
1859+
df1 = pd.DataFrame({"a": ["foo", "bar"], "b": np.array([1, 2], dtype=np.intc)})
1860+
df2 = pd.DataFrame({"a": ["foo", "baz"], "b": np.array([3, 4], dtype=np.intc)})
1861+
result = df1.merge(df2, how="outer")
1862+
expected = pd.DataFrame(
1863+
{
1864+
"a": ["bar", "baz", "foo", "foo"],
1865+
"b": np.array([2, 4, 1, 3], dtype=np.intc),
1866+
}
1867+
)
1868+
tm.assert_frame_equal(result.reset_index(drop=True), expected)
1869+
1870+
def test_merge_intc_non_monotonic(self):
1871+
df = pd.DataFrame({"join_key": pd.Series([0, 2, 1], dtype=np.intc)})
1872+
df_details = pd.DataFrame({"join_key": pd.Series([0, 1, 2], dtype=np.intc),"value": ["a", "b", "c"]})
1873+
merged = pd.merge(df, df_details, on="join_key", how="left")
1874+
expected = pd.DataFrame(
1875+
{
1876+
'join_key':np.array([0,2,1],dtype=np.intc),
1877+
'value':['a','c','b']
1878+
}
1879+
)
1880+
tm.assert_frame_equal(merged.reset_index(drop=True),expected)
1881+
1882+
18591883

18601884

18611885
@pytest.fixture

0 commit comments

Comments
 (0)