We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent 55dc32d commit 386b566Copy full SHA for 386b566
pandas/core/computation/pytables.py
@@ -239,8 +239,13 @@ def stringify(value):
239
if conv_val not in metadata:
240
result = -1
241
else:
242
- # Find the index of the first match of conv_val in metadata
243
- result = np.where(metadata == conv_val)[0][0]
+ # Check if metadata is sorted
+ if np.all(metadata[:-1] <= metadata[1:]):
244
+ # If it is, use searchsorted for efficient lookup
245
+ result = metadata.searchsorted(conv_val, side="left")
246
+ else:
247
+ # Find the index of the first match of conv_val in metadata
248
+ result = np.flatnonzero(metadata == conv_val)[0]
249
return TermValue(result, result, "integer")
250
elif kind == "integer":
251
try:
0 commit comments