![](/img/trans.png)
[英]Why do i get the TypeError “argument of type 'type' is not iterable”?
[英]Why do get a "TypeError: argument of type 'float' is not iterable" on a series with strings and NaN?
對於包含字符串和 NaN 值的系列,為什么series.apply(not_happy)
其中 not_happy 定義為:
def not_happy(element):
if 'subtring' in element:
return True
else:
return False
給出錯誤"TypeError: argument of type 'float' is not iterable"
您在不是 str 類型的系列中應用函數的值之一,或者您可能有一些缺失值。
檢查元素的數據類型。
def not_happy(element): if 'subtring' in str(element): return True else: return False
這將使您的元素字符串類型和工作。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.