我有一个包含值的列表,其中一个值是“ nan”
countries= [nan, 'USA', 'UK', 'France']
我试图删除它,但我每次都得到一个错误
cleanedList = [x for x in countries if (math.isnan(x) == True)]
TypeError: a float is required
当我尝试这个的时候:
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''