![](/img/trans.png)
[英]Pandas Dataframe has a column that contains 'list' data-structure as entries. How to Groupby() them?
[英]Pandas Dataframe has a column that contains 'list' data-structure as entries. How to Groupby() them?
Python TypeError: unhashable type: 'list' 通常意味着列表被用作 hash 參數。 當嘗試 hash 列表時會發生此錯誤,該列表是不可散列的 object。例如,使用列表作為 Python 字典中的鍵將導致此錯誤,因為字典只接受可散列數據類型作為鍵。
解決這個問題的標准方法是將列表轉換為元組,這是一種可散列的數據類型。
tuple()
function 用於將列表轉換為元組。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.