ValueError: cannot index with vector containing NA / NaN values

#找出target中包含字符1的列
y = test[test['target'].str.contains('1')]

报错:ValueError: cannot index with vector containing NA / NaN values

解决方法:

#找出target中包含字符1的列
y = test[test['target'].str.contains('1', case=False, na=False)]


#If first line failed still is possible replace NaNs in condition in str.contains by parameter na=False:

mask = dframe.Product.str.contains(word, case=False, na=False)
#Or try omit inplace=True and assign back:
dframe['Product'] = dframe['Product'].fillna('')

 

na=False

 

na=False

 

na=False

 

na=False

posted @ 2020-11-11 17:06  cup_leo  阅读(1002)  评论(0编辑  收藏  举报