Skip to content

Commit c8248dd

Browse files
committed
Added test for corr with duplicated series names
see #4934 (comment)
1 parent 453162c commit c8248dd

File tree

1 file changed

+24
-0
lines changed

1 file changed

+24
-0
lines changed

dask/dataframe/tests/test_dataframe.py

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2437,6 +2437,30 @@ def test_corr():
24372437
pytest.raises(NotImplementedError, lambda: da.corr(db, method='spearman'))
24382438
pytest.raises(TypeError, lambda: da.corr(ddf))
24392439

2440+
# Series with same names (see https://github.com/dask/dask/issues/4906)
2441+
a = df.A
2442+
b = df.B.rename('A')
2443+
da = dd.from_pandas(a, npartitions=6)
2444+
db = dd.from_pandas(b, npartitions=7)
2445+
2446+
res = da.corr(db)
2447+
res2 = da.corr(db, split_every=2)
2448+
res3 = da.corr(db, min_periods=10)
2449+
res4 = da.corr(db, min_periods=10, split_every=2)
2450+
sol = da.corr(db)
2451+
sol2 = da.corr(db, min_periods=10)
2452+
assert_eq(res, sol)
2453+
assert_eq(res2, sol)
2454+
assert_eq(res3, sol2)
2455+
assert_eq(res4, sol2)
2456+
assert res._name == da.corr(db)._name
2457+
assert res._name != res2._name
2458+
assert res3._name != res4._name
2459+
assert res._name != res3._name
2460+
2461+
pytest.raises(NotImplementedError, lambda: da.corr(db, method='spearman'))
2462+
pytest.raises(TypeError, lambda: da.corr(ddf))
2463+
24402464

24412465
def test_cov_corr_meta():
24422466
df = pd.DataFrame({'a': np.array([1, 2, 3]),

0 commit comments

Comments
 (0)