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

Method test_alignment

pandas/tests/test_multilevel.py:95–113  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

93 assert (df[2000, 1, 10] == df[2000, 1, 7]).all()
94
95 def test_alignment(self):
96 x = Series(
97 data=[1, 2, 3], index=MultiIndex.from_tuples([("A", 1), ("A", 2), ("B", 3)])
98 )
99
100 y = Series(
101 data=[4, 5, 6], index=MultiIndex.from_tuples([("Z", 1), ("Z", 2), ("B", 3)])
102 )
103
104 res = x - y
105 exp_index = x.index.union(y.index)
106 exp = x.reindex(exp_index) - y.reindex(exp_index)
107 tm.assert_series_equal(res, exp)
108
109 # hit non-monotonic code path
110 res = x[::-1] - y[::-1]
111 exp_index = x.index.union(y.index)
112 exp = x.reindex(exp_index) - y.reindex(exp_index)
113 tm.assert_series_equal(res, exp)
114
115 def test_groupby_multilevel(self, multiindex_year_month_day_dataframe_random_data):
116 ymd = multiindex_year_month_day_dataframe_random_data

Callers

nothing calls this directly

Calls 4

reindexMethod · 0.95
SeriesClass · 0.90
from_tuplesMethod · 0.45
unionMethod · 0.45

Tested by

no test coverage detected