NumPy Insert Error: Converting String to Float in NumPy Array
The error 'ValueError: could not convert string to float: '...' is encountered because you're attempting to insert a string ('...') into a NumPy array that expects numeric values.
To insert the string '...' into the NumPy array, convert the array to a data type that accommodates strings. The 'object' data type can store any Python object, including strings. Here's an example:
db_descriptors2 = np.insert(db_descriptors, 2, '...', axis=0).astype(object)
In this example, axis=0 inserts the string as a new row in the array.
If you intend to insert a numeric value, replace the string '...' with a valid numeric value within the np.insert() function.
原文地址: https://www.cveoy.top/t/topic/qr0l 著作权归作者所有。请勿转载和采集!