Skip to content

BUG: reading from a store with duplicate columns across dtypes would raise (GH4767) #4768

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
Sep 7, 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
1 change: 1 addition & 0 deletions doc/source/release.rst
Original file line number Diff line number Diff line change
Expand Up @@ -237,6 +237,7 @@ See :ref:`Internal Refactoring<whatsnew_0130.refactoring>`
- ``read_hdf`` was not respecting as passed ``mode`` (:issue:`4504`)
- appending a 0-len table will work correctly (:issue:`4273`)
- ``to_hdf`` was raising when passing both arguments ``append`` and ``table`` (:issue:`4584`)
- reading from a store with duplicate columns across dtypes would raise (:issue:`4767`)
- Fixed bug in tslib.tz_convert(vals, tz1, tz2): it could raise IndexError exception while
trying to access trans[pos + 1] (:issue:`4496`)
- The ``by`` argument now works correctly with the ``layout`` argument
Expand Down
4 changes: 2 additions & 2 deletions pandas/io/pytables.py
Original file line number Diff line number Diff line change
Expand Up @@ -3219,7 +3219,7 @@ def read(self, where=None, columns=None, **kwargs):
if len(objs) == 1:
wp = objs[0]
else:
wp = concat(objs, axis=0, verify_integrity=True)
wp = concat(objs, axis=0, verify_integrity=False)

# apply the selection filters & axis orderings
wp = self.process_axes(wp, columns=columns)
Expand Down Expand Up @@ -3510,7 +3510,7 @@ def read(self, where=None, columns=None, **kwargs):
if len(frames) == 1:
df = frames[0]
else:
df = concat(frames, axis=1, verify_integrity=True)
df = concat(frames, axis=1, verify_integrity=False)

# apply the selection filters & axis orderings
df = self.process_axes(df, columns=columns)
Expand Down
23 changes: 23 additions & 0 deletions pandas/io/tests/test_pytables.py
Original file line number Diff line number Diff line change
Expand Up @@ -2296,6 +2296,29 @@ def test_wide_table(self):
wp = tm.makePanel()
self._check_roundtrip_table(wp, assert_panel_equal)

def test_select_with_dups(self):


# single dtypes
df = DataFrame(np.random.randn(10,4),columns=['A','A','B','B'])
df.index = date_range('20130101 9:30',periods=10,freq='T')

with ensure_clean(self.path) as store:
store.append('df',df)
result = store.select('df')
assert_frame_equal(result,df)

# dups accross dtypes
df = concat([DataFrame(np.random.randn(10,4),columns=['A','A','B','B']),
DataFrame(np.random.randint(0,10,size=20).reshape(10,2),columns=['A','C'])],
axis=1)
df.index = date_range('20130101 9:30',periods=10,freq='T')

with ensure_clean(self.path) as store:
store.append('df',df)
result = store.select('df')
assert_frame_equal(result,df)

def test_wide_table_dups(self):
wp = tm.makePanel()
with ensure_clean(self.path) as store:
Expand Down