MCPcopy
hub / github.com/pandas-dev/pandas / test_align

Function test_align

pandas/tests/series/methods/test_align.py:25–52  ·  view source on GitHub ↗
(datetime_series, first_slice, second_slice, join_type, fill)

Source from the content-addressed store, hash-verified

23)
24@pytest.mark.parametrize("fill", [None, -1])
25def test_align(datetime_series, first_slice, second_slice, join_type, fill):
26 a = datetime_series[slice(*first_slice)]
27 b = datetime_series[slice(*second_slice)]
28
29 aa, ab = a.align(b, join=join_type, fill_value=fill)
30
31 join_index = a.index.join(b.index, how=join_type)
32 if fill is not None:
33 diff_a = aa.index.difference(join_index)
34 diff_b = ab.index.difference(join_index)
35 if len(diff_a) > 0:
36 assert (aa.reindex(diff_a) == fill).all()
37 if len(diff_b) > 0:
38 assert (ab.reindex(diff_b) == fill).all()
39
40 ea = a.reindex(join_index)
41 eb = b.reindex(join_index)
42
43 if fill is not None:
44 ea = ea.fillna(fill)
45 eb = eb.fillna(fill)
46
47 tm.assert_series_equal(aa, ea)
48 tm.assert_series_equal(ab, eb)
49 assert aa.name == "ts"
50 assert ea.name == "ts"
51 assert ab.name == "ts"
52 assert eb.name == "ts"
53
54
55def test_align_nocopy(datetime_series):

Callers

nothing calls this directly

Calls 6

alignMethod · 0.80
joinMethod · 0.45
differenceMethod · 0.45
allMethod · 0.45
reindexMethod · 0.45
fillnaMethod · 0.45

Tested by

no test coverage detected