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

Method test_ignore_multiindex

pandas/tests/reshape/test_melt.py:384–400  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

382 tm.assert_frame_equal(result, expected)
383
384 def test_ignore_multiindex(self):
385 # GH 17440
386 index = pd.MultiIndex.from_tuples(
387 [("first", "second"), ("first", "third")], names=["baz", "foobar"]
388 )
389 df = DataFrame({"foo": [0, 1], "bar": [2, 3]}, index=index)
390 result = melt(df, ignore_index=False)
391
392 expected_index = pd.MultiIndex.from_tuples(
393 [("first", "second"), ("first", "third")] * 2, names=["baz", "foobar"]
394 )
395 expected = DataFrame(
396 {"variable": ["foo"] * 2 + ["bar"] * 2, "value": [0, 1, 2, 3]},
397 index=expected_index,
398 )
399
400 tm.assert_frame_equal(result, expected)
401
402 def test_ignore_index_name_and_type(self):
403 # GH 17440

Callers

nothing calls this directly

Calls 3

DataFrameClass · 0.90
meltFunction · 0.90
from_tuplesMethod · 0.45

Tested by

no test coverage detected