Skip to content

BUG: values array for non-unique, interleaved cols incorrect #4460

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Aug 5, 2013
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 5 additions & 4 deletions pandas/core/internals.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
11 changes: 11 additions & 0 deletions pandas/tests/test_internals.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down