Skip to content

Commit c8ed2c3

Browse files
committed
Make sure the index being subsetted is less than the row length, not contained in the index
1 parent 7ef4f84 commit c8ed2c3

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

shiny/render/_data_frame.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -493,14 +493,14 @@ def _subset_data_view(selected: bool) -> pd.DataFrame:
493493
if cell_selection is not None and cell_selection["type"] == "row":
494494
# Use a `set` for faster lookups
495495
selected_row_indices_set = set(cell_selection["rows"])
496+
nrow = data.shape[0]
496497

497498
# Subset the data view indices to only include the selected rows that are in the data
498499
data_view_indices = [
499500
index
500501
for index in data_view_indices
501-
if index in selected_row_indices_set
502-
and index
503-
in data.index # pyright: ignore[reportUnknownMemberType]
502+
# Make sure the index is not larger than the number of rows
503+
if index in selected_row_indices_set and index < nrow
504504
]
505505

506506
return data.iloc[data_view_indices]

0 commit comments

Comments
 (0)