Skip to content

Commit 825a02a

Browse files
martinRenougaborbernat
authored andcommitted
Review comment
Signed-off-by: martinRenou <[email protected]>
1 parent 875c9a9 commit 825a02a

File tree

1 file changed

+4
-7
lines changed

1 file changed

+4
-7
lines changed

ipydatagrid/datagrid.py

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -896,13 +896,10 @@ def _get_row_index_of_primary_key(self, value):
896896
"as the primary key."
897897
)
898898

899-
# TODO Is there a better way for this?
900-
row_indices = [
901-
idx
902-
for idx, row in self._data["data"].iterrows()
903-
if all(row[key[j]] == value[j] for j in range(len(key)))
904-
]
905-
return row_indices
899+
df = self._data["data"]
900+
return pd.RangeIndex(len(df))[
901+
(df[key] == value).all(axis="columns")
902+
].to_list()
906903

907904
@staticmethod
908905
def _get_cell_value_by_numerical_index(data, column_index, row_index):

0 commit comments

Comments
 (0)