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

Function test_align_axis

dask/dataframe/tests/test_dataframe.py:1764–1802  ·  view source on GitHub ↗
(join)

Source from the content-addressed store, hash-verified

1762
1763@pytest.mark.parametrize("join", ["inner", "outer", "left", "right"])
1764def test_align_axis(join):
1765 df1a = pd.DataFrame(
1766 {"A": np.random.randn(10), "B": np.random.randn(10), "C": np.random.randn(10)},
1767 index=[1, 12, 5, 6, 3, 9, 10, 4, 13, 11],
1768 )
1769
1770 df1b = pd.DataFrame(
1771 {"B": np.random.randn(10), "C": np.random.randn(10), "D": np.random.randn(10)},
1772 index=[0, 3, 2, 10, 5, 6, 7, 8, 12, 13],
1773 )
1774 ddf1a = dd.from_pandas(df1a, 3)
1775 ddf1b = dd.from_pandas(df1b, 3)
1776
1777 res1, res2 = ddf1a.align(ddf1b, join=join, axis=0)
1778 exp1, exp2 = df1a.align(df1b, join=join, axis=0)
1779 assert assert_eq(res1, exp1)
1780 assert assert_eq(res2, exp2)
1781
1782 res1, res2 = ddf1a.align(ddf1b, join=join, axis=1)
1783 exp1, exp2 = df1a.align(df1b, join=join, axis=1)
1784 assert assert_eq(res1, exp1)
1785 assert assert_eq(res2, exp2)
1786
1787 res1, res2 = ddf1a.align(ddf1b, join=join, axis="index")
1788 exp1, exp2 = df1a.align(df1b, join=join, axis="index")
1789 assert assert_eq(res1, exp1)
1790 assert assert_eq(res2, exp2)
1791
1792 res1, res2 = ddf1a.align(ddf1b, join=join, axis="columns")
1793 exp1, exp2 = df1a.align(df1b, join=join, axis="columns")
1794 assert assert_eq(res1, exp1)
1795 assert assert_eq(res2, exp2)
1796
1797 # invalid
1798 with pytest.raises(ValueError):
1799 ddf1a.align(ddf1b, join=join, axis="XXX")
1800
1801 with pytest.raises(ValueError):
1802 ddf1a["A"].align(ddf1b["B"], join=join, axis=1)
1803
1804
1805def test_combine():

Callers

nothing calls this directly

Calls 2

assert_eqFunction · 0.90
alignMethod · 0.45

Tested by

no test coverage detected