Error type:
UFUNC 'Add' did not contain a loop with signature matching types (dtype ('& lt; U32'), dtype ('& lt; U32') - & gt; dtype('<U32')
The ‘Add’ function is a self-defined addition function. The error type is translated as: UFUNC ‘Add’ does not contain a loop with signature matching type. Check the error causes of others. Most of them are due to data type mismatch. The following add function will report this error when x is of type int and y is of type str.
def add(x,y):
print(type(x))
print(type(y))
return x+y
Therefore, I added a function to view the data type in the add function, and found that the data type is:
<class 'numpy.float64'>
<class 'list'>
This confused me. I rechecked my function again
df1["property_grid"]=df1[["wgs84_lon","wgs84_lat"]].apply(lambda x: add( x["wgs84_lon"], ["wgs84_lat"]),axis=1)
It is found that an X is missing. The correct is as follows:
df1["property_grid"]=df1[["wgs84_lon","wgs84_lat"]].apply(lambda x: add( x["wgs84_lon"], x["wgs84_lat"]),axis=1)
Perfect solution~
Read More:
- [How to Fix] TypeError: Cannot cast array data from dtype(‘float64‘) to dtype(‘<U32‘)….
- [Solved] RuntimeError: scatter(): Expected dtype int64 for index
- [Solved] Matplotlib scatter Draw Error: TypeError: ufunc ‘sqrt‘ not supported for the input types…rule ‘‘safe‘‘
- [Solved] RuntimeError: gather(): Expected dtype int64 for index
- dtype=np.int error: DeprecationWarning: `np.int` is a deprecated alias for the builtin `int`.
- Python quote error: * * * keyerror: u ‘\ uxx’ [How to Solve]
- [Solved] cv2.error: (-215:Assertion failed) encoder->isFormatSupported(CV_8U) in function ‘imwrite_‘
- [Solved] Pandas dataframe merge error: Different types cannot be merged
- [Solved] RuntimeError: run loop already started raise RuntimeError(‘run loop already started‘)
- [Solved] Python Error: asyncio RuntimeError: This event loop is already running
- Python Error: SyntaxError: ‘break‘ outside loop
- The matching result of Python XPath is null
- [Solved] Jupyter notebook: TypeError: __init__() got an unexpected keyword argument ‘io_loop’
- [Solved] django.core.exceptions.ImproperlyConfigured: Error loading MySQLdb module.Did you install mysqlclie
- [Solved] ERROR: No matching distribution found for torch-cluster==x.x.x
- RuntimeError: Failed to register operator torchvision::_new_empty_tensor_op. +torch&torchversion Version Matching
- [Solved] Django Access to the backend error: Invalid block tag on line 98: ‘trans‘, expected ‘elif , ‘else‘或‘ endif. Did you forget
- Python: How to Auto Add Watermark to PDF
- [Solved] TypeError: Object of type ‘bytes’ is not JSON serializable
- To silence this warning, use `float` by itself. Doing this will not modify any behavior and is safe.