Tôi có một danh sách đếm các giá trị, một trong những giá trị tôi nhận được là 'nan'
countries= [nan, 'USA', 'UK', 'France']
Tôi đã cố gắng xóa nó, nhưng tôi luôn gặp lỗi
cleanedList = [x for x in countries if (math.isnan(x) == True)]
TypeError: a float is required
Khi tôi thử cái này:
cleanedList = cities[np.logical_not(np.isnan(countries))]
cleanedList = cities[~np.isnan(countries)]
TypeError: ufunc 'isnan' not supported for the input types, and the inputs could not be safely coerced to any supported types according to the casting rule ''safe''
"nan", không phải là giá trị NaN thực tế.