unhashable type 🐍 Python

TypeError: unhashable type: 'list'

A mutable object (list, dict, set) was used as a dict key or set member.

Seen on: Python

Meaning

Dict keys and set members must be hashable (immutable). Convert lists to tuples, or use a different key.

Common causes

  • Using a list as a dict key
  • Adding dicts to a set
  • groupby/drop_duplicates on columns containing lists (pandas)

⚡ Quick fix

  1. Convert to tuple: d[tuple(key)]
  2. Use frozenset for set-of-sets
  3. Serialize to a string key if needed

Detailed fix by platform

Python

  1. seen = {tuple(row) for row in rows}

How to diagnose

  1. Type — Which type is unhashable?
  2. Usage — Key, set member, or pandas operation?

🧠 Still stuck? Analyze your error

Paste the full message, response headers or stack trace — we'll detect the platform and point to the most likely cause.