TypeError: unhashable type: 'numpy.ndarray' when I use Series.str.len() in pandas query?
The problem is probably with the versions of numexpr. This module evaluates all string expressions for Pandas like query or pd.eval.
The solution is to upgrade your version of numexpr (or remove and reinstall it).
I encountered an issue that when I use Series.str.len() in pandas query method, and actually all the functions for Series.str is not supported in some of my envs, but work in other envs, and all these envs have almost same version of pandas and numpy. (I'm sure Series.str.xxxxx could work in all my envs before)
Env1
Python 3.9.7
numpy==1.21.4
pandas==1.3.4
When I ran pd.DataFrame(columns=['core_text']).query("core_text.str.len()>1"), it raised

Traceback (most recent call last):
File "", line 1, in 
File "/Users/huhon/miniconda3/envs/venv_dev/lib/python3.9/site-packages/pandas/core/frame.py", line 4060, in query
res = self.eval(expr, **kwargs)
File "/Users/huhon/miniconda3/envs/venv_dev/lib/python3.9/site-packages/pandas/core/frame.py", line 4191, in eval
return _eval(expr, inplace=inplace, **kwargs)
File "/Users/huhon/miniconda3/envs/venv_dev/lib/python3.9/site-packages/pandas/core/computation/eval.py", line 353, in eval
ret = eng_inst.evaluate()
File "/Users/huhon/miniconda3/envs/venv_dev/lib/python3.9/site-packages/pandas/core/computation/engines.py", line 80, in evaluate
res = self._evaluate()
File "/Users/huhon/miniconda3/envs/venv_dev/lib/python3.9/site-packages/pandas/core/computation/engines.py", line 120, in _evaluate
_check_ne_builtin_clash(self.expr)
File "/Users/huhon/miniconda3/envs/venv_dev/lib/python3.9/site-packages/pandas/core/computation/engines.py", line 36, in _check_ne_builtin_clash
names = expr.names
File "/Users/huhon/miniconda3/envs/venv_dev/lib/python3.9/site-packages/pandas/core/computation/expr.py", line 834, in names
return frozenset(term.name for term in com.flatten(self.terms))
TypeError: unhashable type: 'numpy.ndarray'

Env2
Python 3.9.9
numpy==1.21.4
pandas==1.3.4
It works perfected.
Anyone can help? Thanks in advance!
Hong