Skip to content

Commit 03d44f3

Browse files
JosephWagnerjreback
authored andcommitted
BUG: select_as_multiple doesn't respect start/stop kwargs GH16209 (#16317)
1 parent d31ffdb commit 03d44f3

File tree

3 files changed

+20
-3
lines changed

3 files changed

+20
-3
lines changed

doc/source/whatsnew/v0.20.2.txt

+1
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,7 @@ I/O
7171
- Bug that would force importing of the clipboard routines unnecessarily, potentially causing an import error on startup (:issue:`16288`)
7272
- Bug that raised IndexError HTML-rendering an empty DataFrame (:issue:`15953`)
7373

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

7576
Plotting
7677
^^^^^^^^

pandas/io/pytables.py

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

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

837837
# concat and return
838838
return concat(objs, axis=axis,
@@ -1425,7 +1425,8 @@ def get_result(self, coordinates=False):
14251425

14261426
# if specified read via coordinates (necessary for multiple selections
14271427
if coordinates:
1428-
where = self.s.read_coordinates(where=self.where)
1428+
where = self.s.read_coordinates(where=self.where, start=self.start,
1429+
stop=self.stop)
14291430
else:
14301431
where = self.where
14311432

pandas/tests/io/test_pytables.py

+15
Original file line numberDiff line numberDiff line change
@@ -4219,6 +4219,21 @@ def test_start_stop_table(self):
42194219
expected = df.loc[30:40, ['A']]
42204220
tm.assert_frame_equal(result, expected)
42214221

4222+
def test_start_stop_multiple(self):
4223+
4224+
# GH 16209
4225+
with ensure_clean_store(self.path) as store:
4226+
4227+
df = DataFrame({"foo": [1, 2], "bar": [1, 2]})
4228+
4229+
store.append_to_multiple({'selector': ['foo'], 'data': None}, df,
4230+
selector='selector')
4231+
result = store.select_as_multiple(['selector', 'data'],
4232+
selector='selector', start=0,
4233+
stop=1)
4234+
expected = df.loc[[0], ['foo', 'bar']]
4235+
tm.assert_frame_equal(result, expected)
4236+
42224237
def test_start_stop_fixed(self):
42234238

42244239
with ensure_clean_store(self.path) as store:

0 commit comments

Comments
 (0)