Search code examples
pythonpandasfunctionapplyiterable

Why do get a "TypeError: argument of type 'float' is not iterable" on a series with strings and NaN?


For a series containing strings and NaN values, why does series.apply(not_happy)

where not_happy is defined by:

def not_happy(element):
    if 'subtring' in element:
        return True
    else:
        return False

gives the error "TypeError: argument of type 'float' is not iterable"


Solution

  • One of the values in the series you're applying the funciton on in not of str type or probably you have some missing values.