Skip to content

Commit

Permalink
BUG: select_as_multiple doesn't respect start/stop kwargs GH16209 (pa…
Browse files Browse the repository at this point in the history
  • Loading branch information
JosephWagner authored and jreback committed May 31, 2017
1 parent d31ffdb commit 03d44f3
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 3 deletions.
1 change: 1 addition & 0 deletions doc/source/whatsnew/v0.20.2.txt
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,7 @@ I/O
- Bug that would force importing of the clipboard routines unnecessarily, potentially causing an import error on startup (:issue:`16288`)
- Bug that raised IndexError HTML-rendering an empty DataFrame (:issue:`15953`)

- Bug in ``HDFStore.select_as_multiple()`` where start/stop arguments were not respected (:issue:`16209`)

Plotting
^^^^^^^^
Expand Down
7 changes: 4 additions & 3 deletions pandas/io/pytables.py
Original file line number Diff line number Diff line change
Expand Up @@ -831,8 +831,8 @@ def func(_start, _stop, _where):

# retrieve the objs, _where is always passed as a set of
# coordinates here
objs = [t.read(where=_where, columns=columns, **kwargs)
for t in tbls]
objs = [t.read(where=_where, columns=columns, start=_start,
stop=_stop, **kwargs) for t in tbls]

# concat and return
return concat(objs, axis=axis,
Expand Down Expand Up @@ -1425,7 +1425,8 @@ def get_result(self, coordinates=False):

# if specified read via coordinates (necessary for multiple selections
if coordinates:
where = self.s.read_coordinates(where=self.where)
where = self.s.read_coordinates(where=self.where, start=self.start,
stop=self.stop)
else:
where = self.where

Expand Down
15 changes: 15 additions & 0 deletions pandas/tests/io/test_pytables.py
Original file line number Diff line number Diff line change
Expand Up @@ -4219,6 +4219,21 @@ def test_start_stop_table(self):
expected = df.loc[30:40, ['A']]
tm.assert_frame_equal(result, expected)

def test_start_stop_multiple(self):

# GH 16209
with ensure_clean_store(self.path) as store:

df = DataFrame({"foo": [1, 2], "bar": [1, 2]})

store.append_to_multiple({'selector': ['foo'], 'data': None}, df,
selector='selector')
result = store.select_as_multiple(['selector', 'data'],
selector='selector', start=0,
stop=1)
expected = df.loc[[0], ['foo', 'bar']]
tm.assert_frame_equal(result, expected)

def test_start_stop_fixed(self):

with ensure_clean_store(self.path) as store:
Expand Down

0 comments on commit 03d44f3

Please sign in to comment.