Skip to content

Commit 7c461b2

Browse files
author
Joseph Wagner
committed
BUG: select_as_multiple doesn't respect start/stop kwargs GH16209
1 parent 81aa70c commit 7c461b2

File tree

3 files changed

+19
-3
lines changed

3 files changed

+19
-3
lines changed

doc/source/whatsnew/v0.21.0.txt

+1
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,7 @@ Indexing
8282
I/O
8383
^^^
8484

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

8687

8788
Plotting

pandas/io/pytables.py

+4-3
Original file line numberDiff line numberDiff line change
@@ -826,8 +826,8 @@ def func(_start, _stop, _where):
826826

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

832832
# concat and return
833833
return concat(objs, axis=axis,
@@ -1420,7 +1420,8 @@ def get_result(self, coordinates=False):
14201420

14211421
# if specified read via coordinates (necessary for multiple selections
14221422
if coordinates:
1423-
where = self.s.read_coordinates(where=self.where)
1423+
where = self.s.read_coordinates(where=self.where, start=self.start,
1424+
stop=self.stop)
14241425
else:
14251426
where = self.where
14261427

pandas/tests/io/test_pytables.py

+14
Original file line numberDiff line numberDiff line change
@@ -4186,6 +4186,20 @@ def test_start_stop_table(self):
41864186
expected = df.loc[30:40, ['A']]
41874187
tm.assert_frame_equal(result, expected)
41884188

4189+
def test_start_stop_multiple(self):
4190+
4191+
with ensure_clean_store(self.path) as store:
4192+
4193+
df = DataFrame({"foo": [1, 2], "bar": [1, 2]})
4194+
4195+
store.append_to_multiple({'selector': ['foo'], 'data': None}, df,
4196+
selector='selector')
4197+
result = store.select_as_multiple(['selector', 'data'],
4198+
selector='selector', start=0,
4199+
stop=1)
4200+
expected = df[['foo', 'bar']].iloc[[0]]
4201+
tm.assert_frame_equal(result, expected)
4202+
41894203
def test_start_stop_fixed(self):
41904204

41914205
with ensure_clean_store(self.path) as store:

0 commit comments

Comments
 (0)