im getting error: ufunc 'add' did not contain a loop with signature matching types…
- User
im getting error: ufunc 'add' did not contain a loop with signature matching types (dtype('int64'), dtype('<U16')) -> None
code: def calculate_priority(row):
print('---------------------------->> calculate_priority') high_index = np.argmax(row[high_cols].values) low_index = np.argmin(row[low_cols].values) print(low_index + " -------------- " + high_index) if low_index is None: return 0 if high_index is None: return 0 return int(high_index < low_index) - Assistant
The issue you're encountering is due to the attempt to concatenate strings (
str) with integers (int) without explicit conversion, within theprintstatement:print(low_index + " -------------- " + high_index)numpy.argmax()andnumpy.argmin()return integers, which you're trying to concatenate with strings using the+operator. This operation is not allowed in Python without explicitly converting the integers to strings.To fix this error, you can modify the
printstatement to explicitly convert and to strings using function, like so: