Skip to content

Commit 79cc4a9

Browse files
JosephWagnerKiv
authored andcommitted
BUG: select_as_multiple doesn't respect start/stop kwargs GH16209 (pandas-dev#16317)
1 parent 9a9c315 commit 79cc4a9

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
@@ -806,8 +806,8 @@ def func(_start, _stop, _where):
806806

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

812812
# concat and return
813813
return concat(objs, axis=axis,
@@ -1432,7 +1432,8 @@ def get_result(self, coordinates=False):
14321432

14331433
# if specified read via coordinates (necessary for multiple selections
14341434
if coordinates:
1435-
where = self.s.read_coordinates(where=self.where)
1435+
where = self.s.read_coordinates(where=self.where, start=self.start,
1436+
stop=self.stop)
14361437
else:
14371438
where = self.where
14381439

pandas/tests/io/test_pytables.py

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

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

42264241
with ensure_clean_store(self.path) as store:

0 commit comments

Comments
 (0)