Skip to content

BUG: select_as_multiple doesn't respect start/stop kwargs GH16209 #16317

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 2 commits into from
May 31, 2017
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/whatsnew/v0.20.2.txt
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ I/O

- Bug that would force importing of the clipboard routines unnecessarily, potentially causing an import error on startup (:issue:`16288`)

- 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 @@ -826,8 +826,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 @@ -1420,7 +1420,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 @@ -4186,6 +4186,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):

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can you add the issue number as a comment

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can you add the issue number

# 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