Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
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.21.0.txt
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,7 @@ Indexing
I/O
^^^

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

Choose a reason for hiding this comment

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

you can put this in 0.20.2

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 move this



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
14 changes: 14 additions & 0 deletions pandas/tests/io/test_pytables.py
Original file line number Diff line number Diff line change
Expand Up @@ -4186,6 +4186,20 @@ 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

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[['foo', 'bar']].iloc[[0]]
Copy link
Contributor

Choose a reason for hiding this comment

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

df.loc[[0], ['foo', 'bar']] is more idiomatic

tm.assert_frame_equal(result, expected)

def test_start_stop_fixed(self):

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