def test_unstack_to_series(self):
    data = self.frame.unstack()
    assert isinstance(data, Series)
    undo = data.unstack().T
    assert_frame_equal(undo, self.frame)
    data = DataFrame({'x': [1, 2, np.NaN], 'y': [3.0, 4, np.NaN]})
    data.index = Index(['a', 'b', 'c'])
    result = data.unstack()
    midx = MultiIndex(levels=[['x', 'y'], ['a', 'b', 'c']], labels=[[0, 0, 0, 1, 1, 1], [0, 1, 2, 0, 1, 2]])
    expected = Series([1, 2, np.NaN, 3, 4, np.NaN], index=midx)
    assert_series_equal(result, expected)
    old_data = data.copy()
    for _ in range(4):
        data = data.unstack()
    assert_frame_equal(old_data, data)
def test_unstack_to_series(self):
    data = self.frame.unstack()
    assert isinstance(data, Series)
    undo = data.unstack().T
    assert_frame_equal(undo, self.frame)
    data = DataFrame({'x': [1, 2, np.NaN], 'y': [3.0, 4, np.NaN]})
    data.index = Index(['a', 'b', 'c'])
    result = data.unstack()
    midx = MultiIndex(levels=[['x', 'y'], ['a', 'b', 'c']], labels=[[0, 0, 0, 1, 1, 1], [0, 1, 2, 0, 1, 2]])
    expected = Series([1, 2, np.NaN, 3, 4, np.NaN], index=midx)
    assert_series_equal(result, expected)
    old_data = data.copy()
    for _ in range(4):
        data = data.unstack()
    assert_frame_equal(old_data, data)