From c73909eb2d5cca44a6d168b7b217bdd00ca14b1e Mon Sep 17 00:00:00 2001 From: Kieran O'Mahony Date: Mon, 5 Aug 2013 11:31:40 +1000 Subject: [PATCH] BUG: values array for non-unique, interleaved cols incorrect --- pandas/core/internals.py | 9 +++++---- pandas/tests/test_internals.py | 11 +++++++++++ 2 files changed, 16 insertions(+), 4 deletions(-) diff --git a/pandas/core/internals.py b/pandas/core/internals.py index abe70e9037264..56a6c8081d556 100644 --- a/pandas/core/internals.py +++ b/pandas/core/internals.py @@ -1546,15 +1546,16 @@ def _interleave(self, items): result[indexer] = block.get_values(dtype) itemmask[indexer] = 1 - if not itemmask.all(): - raise AssertionError('Some items were not contained in blocks') - else: # non-unique, must use ref_locs rl = self._set_ref_locs() for i, (block, idx) in enumerate(rl): - result[i] = block.iget(idx) + result[i] = block.get_values(dtype)[idx] + itemmask[i] = 1 + + if not itemmask.all(): + raise AssertionError('Some items were not contained in blocks') return result diff --git a/pandas/tests/test_internals.py b/pandas/tests/test_internals.py index 6f13678339425..57827857e107a 100644 --- a/pandas/tests/test_internals.py +++ b/pandas/tests/test_internals.py @@ -457,6 +457,17 @@ def test_xs(self): def test_interleave(self): pass + def test_interleave_non_unique_cols(self): + df = DataFrame([ + [Timestamp('20130101'), 3.5], + [Timestamp('20130102'), 4.5]], + columns=['x', 'x'], + index=[1, 2]) + + df_unique = df.copy() + df_unique.columns = ['x', 'y'] + np.testing.assert_array_equal(df_unique.values, df.values) + def test_consolidate(self): pass