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

Function test_align_axis

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

Source from the content-addressed store, hash-verified

2378
2379@pytest.mark.parametrize("join", ["inner", "outer", "left", "right"])
2380def test_align_axis(join):
2381 df1a = pd.DataFrame(
2382 {"A": np.random.randn(10), "B": np.random.randn(10), "C": np.random.randn(10)},
2383 index=[1, 12, 5, 6, 3, 9, 10, 4, 13, 11],
2384 )
2385
2386 df1b = pd.DataFrame(
2387 {"B": np.random.randn(10), "C": np.random.randn(10), "D": np.random.randn(10)},
2388 index=[0, 3, 2, 10, 5, 6, 7, 8, 12, 13],
2389 )
2390 ddf1a = from_pandas(df1a, 3)
2391 ddf1b = from_pandas(df1b, 3)
2392
2393 res1, res2 = ddf1a.align(ddf1b, join=join, axis=0)
2394 exp1, exp2 = df1a.align(df1b, join=join, axis=0)
2395 assert assert_eq(res1, exp1)
2396 assert assert_eq(res2, exp2)
2397
2398 res1, res2 = ddf1a.align(ddf1b, join=join, axis=1)
2399 exp1, exp2 = df1a.align(df1b, join=join, axis=1)
2400 assert assert_eq(res1, exp1)
2401 assert assert_eq(res2, exp2)
2402
2403 res1, res2 = ddf1a.align(ddf1b, join=join, axis="index")
2404 exp1, exp2 = df1a.align(df1b, join=join, axis="index")
2405 assert assert_eq(res1, exp1)
2406 assert assert_eq(res2, exp2)
2407
2408 res1, res2 = ddf1a.align(ddf1b, join=join, axis="columns")
2409 exp1, exp2 = df1a.align(df1b, join=join, axis="columns")
2410 assert assert_eq(res1, exp1)
2411 assert assert_eq(res2, exp2)
2412
2413 # invalid
2414 with pytest.raises(ValueError):
2415 ddf1a.align(ddf1b, join=join, axis="XXX")
2416
2417 with pytest.raises(ValueError):
2418 ddf1a["A"].align(ddf1b["B"], join=join, axis=1)
2419
2420
2421def 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