def test_stack_mixed_level(self):
    levels = [range(3), [3, 'a', 'b'], [1, 2]]
    df = DataFrame(1, index=levels[0], columns=levels[1])
    result = df.stack()
    expected = Series(1, index=MultiIndex.from_product(levels[:2]))
    assert_series_equal(result, expected)
    df = DataFrame(1, index=levels[0], columns=MultiIndex.from_product(levels[1:]))
    result = df.stack(1)
    expected = DataFrame(1, index=MultiIndex.from_product([levels[0], levels[2]]), columns=levels[1])
    assert_frame_equal(result, expected)
    result = df[['a', 'b']].stack(1)
    expected = expected[['a', 'b']]
    assert_frame_equal(result, expected)
def test_stack_mixed_level(self):
    levels = [range(3), [3, 'a', 'b'], [1, 2]]
    df = DataFrame(1, index=levels[0], columns=levels[1])
    result = df.stack()
    expected = Series(1, index=MultiIndex.from_product(levels[:2]))
    assert_series_equal(result, expected)
    df = DataFrame(1, index=levels[0], columns=MultiIndex.from_product(levels[1:]))
    result = df.stack(1)
    expected = DataFrame(1, index=MultiIndex.from_product([levels[0], levels[2]]), columns=levels[1])
    assert_frame_equal(result, expected)
    result = df[['a', 'b']].stack(1)
    expected = expected[['a', 'b']]
    assert_frame_equal(result, expected)