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

Function test_align_axis

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

Source from the content-addressed store, hash-verified

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