【发布时间】:2021-08-23 04:55:17
【问题描述】:
AttributeError: 'NoneType' 对象没有属性 'lower'
谁能帮我弄清楚如何解决这个错误!?
搜索了很多次,但似乎没有任何效果。
for feature in features:
df[feature] = df[feature].replace('-',None)
def combine_features(row):
try:
return row['genre']+ " " + row['star'] +" " + row['name'] +" " +row[' rating'] +" "+ row['director']
except:
print ("Error",row)
df["Combined_features"] = df.apply(combine_features,axis = 1)
print("Combined Features",df["Combined_features"].head())
cv = CountVectorizer()
count_matrix = cv.fit_transform(df["Combined_features"])
#here it gives error NoneType object has no attribute 'lower'
cosine_sim = cosine_similarity(count_matrix)
movie_user_likes = "Avatar"
【问题讨论】:
-
验证您的
combined_features是否有任何nan值并替换/删除它们。
标签: python pandas numpy matplotlib sklearn-pandas