Skip to content

Commit 6b6689a

Browse files
G26karthikJustine Wezenaar
authored andcommitted
TST: Add regression test for pyarrow datetime merge with duplicates (GH#61926) (pandas-dev#62592)
1 parent 3888917 commit 6b6689a

File tree

1 file changed

+24
-0
lines changed

1 file changed

+24
-0
lines changed

pandas/tests/reshape/merge/test_merge.py

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3097,3 +3097,27 @@ def test_merge_categorical_key_recursion():
30973097
right.astype("float64"), on="key", how="outer"
30983098
)
30993099
tm.assert_frame_equal(result, expected)
3100+
3101+
3102+
def test_merge_pyarrow_datetime_duplicates():
3103+
# GH#61926
3104+
pytest.importorskip("pyarrow")
3105+
3106+
t = pd.date_range("2025-07-06", periods=3, freq="h")
3107+
df1 = DataFrame({"time": t, "val1": [1, 2, 3]})
3108+
df1 = df1.convert_dtypes(dtype_backend="pyarrow")
3109+
3110+
df2 = DataFrame({"time": t.repeat(2), "val2": [10, 20, 30, 40, 50, 60]})
3111+
df2 = df2.convert_dtypes(dtype_backend="pyarrow")
3112+
3113+
result = merge(df1, df2, on="time", how="left")
3114+
3115+
expected = DataFrame(
3116+
{
3117+
"time": t.repeat(2),
3118+
"val1": [1, 1, 2, 2, 3, 3],
3119+
"val2": [10, 20, 30, 40, 50, 60],
3120+
}
3121+
)
3122+
expected = expected.convert_dtypes(dtype_backend="pyarrow")
3123+
tm.assert_frame_equal(result, expected)

0 commit comments

Comments
 (0)