def test_stack_unstack(self):
    df = self.frame.copy()
    df[:] = np.arange(np.prod(df.shape)).reshape(df.shape)
    stacked = df.stack()
    stacked_df = DataFrame({'foo': stacked, 'bar': stacked})
    unstacked = stacked.unstack()
    unstacked_df = stacked_df.unstack()
    assert_frame_equal(unstacked, df)
    assert_frame_equal(unstacked_df['bar'], df)
    unstacked_cols = stacked.unstack(0)
    unstacked_cols_df = stacked_df.unstack(0)
    assert_frame_equal(unstacked_cols.T, df)
    assert_frame_equal(unstacked_cols_df['bar'].T, df)
def test_stack_unstack(self):
    df = self.frame.copy()
    df[:] = np.arange(np.prod(df.shape)).reshape(df.shape)
    stacked = df.stack()
    stacked_df = DataFrame({'foo': stacked, 'bar': stacked})
    unstacked = stacked.unstack()
    unstacked_df = stacked_df.unstack()
    assert_frame_equal(unstacked, df)
    assert_frame_equal(unstacked_df['bar'], df)
    unstacked_cols = stacked.unstack(0)
    unstacked_cols_df = stacked_df.unstack(0)
    assert_frame_equal(unstacked_cols.T, df)
    assert_frame_equal(unstacked_cols_df['bar'].T, df)