MCPcopy
hub / github.com/pydata/xarray / test_unstack

Method test_unstack

xarray/tests/test_indexes.py:448–458  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

446 np.testing.assert_array_equal(index_pd.levels[1], [1, 2])
447
448 def test_unstack(self) -> None:
449 pd_midx = pd.MultiIndex.from_product(
450 [["a", "b"], [1, 2, 3]], names=["one", "two"]
451 )
452 index = PandasMultiIndex(pd_midx, "x")
453
454 new_indexes, new_pd_idx = index.unstack()
455 assert list(new_indexes) == ["one", "two"]
456 assert new_indexes["one"].equals(PandasIndex(["a", "b"], "one"))
457 assert new_indexes["two"].equals(PandasIndex([1, 2, 3], "two"))
458 assert new_pd_idx.equals(pd_midx)
459
460 def test_unstack_requires_unique(self) -> None:
461 pd_midx = pd.MultiIndex.from_product([["a", "a"], [1, 2]], names=["one", "two"])

Callers

nothing calls this directly

Calls 4

unstackMethod · 0.95
PandasMultiIndexClass · 0.90
PandasIndexClass · 0.90
equalsMethod · 0.45

Tested by

no test coverage detected