MCPcopy Create free account
hub / github.com/dask/dask / test_concat3

Function test_concat3

dask/dataframe/tests/test_multi.py:1726–1763  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

1724
1725
1726def test_concat3():
1727 pdf1 = pd.DataFrame(
1728 np.random.randn(6, 5), columns=list("ABCDE"), index=list("abcdef")
1729 )
1730 pdf2 = pd.DataFrame(
1731 np.random.randn(6, 5), columns=list("ABCFG"), index=list("ghijkl")
1732 )
1733 pdf3 = pd.DataFrame(
1734 np.random.randn(6, 5), columns=list("ABCHI"), index=list("mnopqr")
1735 )
1736 ddf1 = dd.from_pandas(pdf1, 2)
1737 ddf2 = dd.from_pandas(pdf2, 3)
1738 ddf3 = dd.from_pandas(pdf3, 2)
1739
1740 expected = pd.concat([pdf1, pdf2], sort=False)
1741 result = dd.concat([ddf1, ddf2])
1742 assert result.divisions == ddf1.divisions[:-1] + ddf2.divisions
1743 assert result.npartitions == ddf1.npartitions + ddf2.npartitions
1744 assert_eq(result, expected)
1745
1746 assert_eq(
1747 dd.concat([ddf1, ddf2], interleave_partitions=True), pd.concat([pdf1, pdf2])
1748 )
1749
1750 expected = pd.concat([pdf1, pdf2, pdf3], sort=False)
1751 result = dd.concat([ddf1, ddf2, ddf3])
1752 assert result.divisions == (
1753 ddf1.divisions[:-1] + ddf2.divisions[:-1] + ddf3.divisions
1754 )
1755 assert result.npartitions == (
1756 ddf1.npartitions + ddf2.npartitions + ddf3.npartitions
1757 )
1758 assert_eq(result, expected)
1759
1760 assert_eq(
1761 dd.concat([ddf1, ddf2, ddf3], interleave_partitions=True),
1762 pd.concat([pdf1, pdf2, pdf3]),
1763 )
1764
1765
1766def test_concat4_interleave_partitions():

Callers

nothing calls this directly

Calls 1

assert_eqFunction · 0.90

Tested by

no test coverage detected