Usage of numexpr contains() function

365 views Asked by At

I want to check if each element of a Numpy string array contains a given string using numexpr (2.7). I have written:

x = np.array(['abc', 'cde'])
ne.evaluate("contains(x, 'a')")

I get: ValueError: unknown type str96

I also tried to specify a dtype for x with the same result

1

There are 1 answers

0
Levon On BEST ANSWER

This is a known issue. Try instead

import numpy as np
import numexpr as ne

x = np.array([b'abc', b'cde'])
ne.evaluate("contains(x, b'a')")
# array([ True, False])