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

Function test_align_axis

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

Source from the content-addressed store, hash-verified

2341
2342@pytest.mark.parametrize("join", ["inner", "outer", "left", "right"])
2343def test_align_axis(join):
2344 df1a = pd.DataFrame(
2345 {"A": np.random.randn(10), "B": np.random.randn(10), "C": np.random.randn(10)},
2346 index=[1, 12, 5, 6, 3, 9, 10, 4, 13, 11],
2347 )
2348
2349 df1b = pd.DataFrame(
2350 {"B": np.random.randn(10), "C": np.random.randn(10), "D": np.random.randn(10)},
2351 index=[0, 3, 2, 10, 5, 6, 7, 8, 12, 13],
2352 )
2353 ddf1a = from_pandas(df1a, 3)
2354 ddf1b = from_pandas(df1b, 3)
2355
2356 res1, res2 = ddf1a.align(ddf1b, join=join, axis=0)
2357 exp1, exp2 = df1a.align(df1b, join=join, axis=0)
2358 assert assert_eq(res1, exp1)
2359 assert assert_eq(res2, exp2)
2360
2361 res1, res2 = ddf1a.align(ddf1b, join=join, axis=1)
2362 exp1, exp2 = df1a.align(df1b, join=join, axis=1)
2363 assert assert_eq(res1, exp1)
2364 assert assert_eq(res2, exp2)
2365
2366 res1, res2 = ddf1a.align(ddf1b, join=join, axis="index")
2367 exp1, exp2 = df1a.align(df1b, join=join, axis="index")
2368 assert assert_eq(res1, exp1)
2369 assert assert_eq(res2, exp2)
2370
2371 res1, res2 = ddf1a.align(ddf1b, join=join, axis="columns")
2372 exp1, exp2 = df1a.align(df1b, join=join, axis="columns")
2373 assert assert_eq(res1, exp1)
2374 assert assert_eq(res2, exp2)
2375
2376 # invalid
2377 with pytest.raises(ValueError):
2378 ddf1a.align(ddf1b, join=join, axis="XXX")
2379
2380 with pytest.raises(ValueError):
2381 ddf1a["A"].align(ddf1b["B"], join=join, axis=1)
2382
2383
2384def 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