Skip to content

Commit a1285cd

Browse files
JosephWagnerTomAugspurger
authored andcommitted
BUG: select_as_multiple doesn't respect start/stop kwargs GH16209 (#16317)
(cherry picked from commit 03d44f3)
1 parent 437ed66 commit a1285cd

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 in ``pd.read_csv()`` in which tarfile object inputs were raising an error in Python 2.x for the C engine (:issue:`16530`)
7272
- Bug where ``DataFrame.to_html()`` ignored the ``index_names`` parameter (:issue:`16493`)
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
@@ -832,8 +832,8 @@ def func(_start, _stop, _where):
832832

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

838838
# concat and return
839839
return concat(objs, axis=axis,
@@ -1426,7 +1426,8 @@ def get_result(self, coordinates=False):
14261426

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

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)