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

Function test_align_axis

dask/dataframe/dask_expr/tests/test_collection.py:2331–2369  ·  view source on GitHub ↗
(join)

Source from the content-addressed store, hash-verified

2329
2330@pytest.mark.parametrize("join", ["inner", "outer", "left", "right"])
2331def test_align_axis(join):
2332 df1a = pd.DataFrame(
2333 {"A": np.random.randn(10), "B": np.random.randn(10), "C": np.random.randn(10)},
2334 index=[1, 12, 5, 6, 3, 9, 10, 4, 13, 11],
2335 )
2336
2337 df1b = pd.DataFrame(
2338 {"B": np.random.randn(10), "C": np.random.randn(10), "D": np.random.randn(10)},
2339 index=[0, 3, 2, 10, 5, 6, 7, 8, 12, 13],
2340 )
2341 ddf1a = from_pandas(df1a, 3)
2342 ddf1b = from_pandas(df1b, 3)
2343
2344 res1, res2 = ddf1a.align(ddf1b, join=join, axis=0)
2345 exp1, exp2 = df1a.align(df1b, join=join, axis=0)
2346 assert assert_eq(res1, exp1)
2347 assert assert_eq(res2, exp2)
2348
2349 res1, res2 = ddf1a.align(ddf1b, join=join, axis=1)
2350 exp1, exp2 = df1a.align(df1b, join=join, axis=1)
2351 assert assert_eq(res1, exp1)
2352 assert assert_eq(res2, exp2)
2353
2354 res1, res2 = ddf1a.align(ddf1b, join=join, axis="index")
2355 exp1, exp2 = df1a.align(df1b, join=join, axis="index")
2356 assert assert_eq(res1, exp1)
2357 assert assert_eq(res2, exp2)
2358
2359 res1, res2 = ddf1a.align(ddf1b, join=join, axis="columns")
2360 exp1, exp2 = df1a.align(df1b, join=join, axis="columns")
2361 assert assert_eq(res1, exp1)
2362 assert assert_eq(res2, exp2)
2363
2364 # invalid
2365 with pytest.raises(ValueError):
2366 ddf1a.align(ddf1b, join=join, axis="XXX")
2367
2368 with pytest.raises(ValueError):
2369 ddf1a["A"].align(ddf1b["B"], join=join, axis=1)
2370
2371
2372def test_quantile_datetime_numeric_only_false():

Callers

nothing calls this directly

Calls 3

from_pandasFunction · 0.90
assert_eqFunction · 0.90
alignMethod · 0.45

Tested by

no test coverage detected