我想問一些幫助,因爲我無法理解Python程序中的TypeError。 這一碼:與系列,列表和獨特元素混淆
users2 = np.random.choice(users,5000).tolist()
print len(users2)
print users2[0:20]
for user in users2:
tags.append(user_counters["tags"].loc[user])
print type(tags)
print set(tags)
標籤的類型是列表。但是,當我申請設置()方法來採取的「標籤」列表中的獨特元素,出現以下錯誤:
TypeError: 'Series' objects are mutable, thus they cannot be hashed
好吧,我明白是什麼意思,但我不明白的事情是「類型系列」。
在另一方面,如果使用:
print tags.unique()
另一個錯誤使得它的外觀:
AttributeError: 'list' object has no attribute 'unique'
注:users_counters是數據幀的類型和用戶型列出及其來自users_counters的元素。
那麼,爲什麼類型錯誤的錯誤發生,因爲標籤是列表和set()是列表?
感謝您在adnvance