Skip to content

Commit 57b0184

Browse files
committed
Merge pull request pandas-dev#4768 from jreback/hdf_dups
BUG: reading from a store with duplicate columns across dtypes would raise (GH4767)
2 parents 22f04f7 + bbb54fd commit 57b0184

File tree

3 files changed

+26
-2
lines changed

3 files changed

+26
-2
lines changed

doc/source/release.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -239,6 +239,7 @@ See :ref:`Internal Refactoring<whatsnew_0130.refactoring>`
239239
- ``read_hdf`` was not respecting as passed ``mode`` (:issue:`4504`)
240240
- appending a 0-len table will work correctly (:issue:`4273`)
241241
- ``to_hdf`` was raising when passing both arguments ``append`` and ``table`` (:issue:`4584`)
242+
- reading from a store with duplicate columns across dtypes would raise (:issue:`4767`)
242243
- Fixed bug in tslib.tz_convert(vals, tz1, tz2): it could raise IndexError exception while
243244
trying to access trans[pos + 1] (:issue:`4496`)
244245
- The ``by`` argument now works correctly with the ``layout`` argument

pandas/io/pytables.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3219,7 +3219,7 @@ def read(self, where=None, columns=None, **kwargs):
32193219
if len(objs) == 1:
32203220
wp = objs[0]
32213221
else:
3222-
wp = concat(objs, axis=0, verify_integrity=True)
3222+
wp = concat(objs, axis=0, verify_integrity=False)
32233223

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

35153515
# apply the selection filters & axis orderings
35163516
df = self.process_axes(df, columns=columns)

pandas/io/tests/test_pytables.py

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2296,6 +2296,29 @@ def test_wide_table(self):
22962296
wp = tm.makePanel()
22972297
self._check_roundtrip_table(wp, assert_panel_equal)
22982298

2299+
def test_select_with_dups(self):
2300+
2301+
2302+
# single dtypes
2303+
df = DataFrame(np.random.randn(10,4),columns=['A','A','B','B'])
2304+
df.index = date_range('20130101 9:30',periods=10,freq='T')
2305+
2306+
with ensure_clean(self.path) as store:
2307+
store.append('df',df)
2308+
result = store.select('df')
2309+
assert_frame_equal(result,df)
2310+
2311+
# dups accross dtypes
2312+
df = concat([DataFrame(np.random.randn(10,4),columns=['A','A','B','B']),
2313+
DataFrame(np.random.randint(0,10,size=20).reshape(10,2),columns=['A','C'])],
2314+
axis=1)
2315+
df.index = date_range('20130101 9:30',periods=10,freq='T')
2316+
2317+
with ensure_clean(self.path) as store:
2318+
store.append('df',df)
2319+
result = store.select('df')
2320+
assert_frame_equal(result,df)
2321+
22992322
def test_wide_table_dups(self):
23002323
wp = tm.makePanel()
23012324
with ensure_clean(self.path) as store:

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy