Pandas version checks

  • [X] I have checked that this issue has not already been reported.

  • [X] I have confirmed this bug exists on the latest version of pandas.

  • [X] I have confirmed this bug exists on the main branch of pandas.

Reproducible Example

>>> df = pd.DataFrame({"col": list("abcde")})
>>> df.col.str.contains('')
0    True
1    True
2    True
3    True
4    True
Name: col, dtype: bool
>>> df = pd.DataFrame({"col": list("abcde")})
>>> df.eval("col.str.contains('')")
...
~\miniconda3\lib\site-packages\pandas\core\computation\expr.py in names(self)
    831         """
    832         if is_term(self.terms):
--> 833             return frozenset([self.terms.name])
    834         return frozenset(term.name for term in com.flatten(self.terms))
    835 

TypeError: unhashable type: 'Series'

Issue Description

When I try to use eval with the expression "col.str.contains('')" it does not work.

Full traceback

---------------------------------------------------------------------------

TypeError                                 Traceback (most recent call last)
C:\Users\USER\AppData\Local\Temp/ipykernel_11200/4113666755.py in <module>
----> 1 df.eval("tags.str.contains('')")

~\miniconda3\lib\site-packages\pandas\core\frame.py in eval(self, expr, inplace, **kwargs)
   4184         kwargs["resolvers"] = kwargs.get("resolvers", ()) + tuple(resolvers)
   4185 
-> 4186         return _eval(expr, inplace=inplace, **kwargs)
   4187 
   4188     def select_dtypes(self, include=None, exclude=None) -> DataFrame:

~\miniconda3\lib\site-packages\pandas\core\computation\eval.py in eval(expr, parser, engine, truediv, local_dict, global_dict, resolvers, level, target, inplace)
    351         eng = ENGINES[engine]
    352         eng_inst = eng(parsed_expr)
--> 353         ret = eng_inst.evaluate()
    354 
    355         if parsed_expr.assigner is None:

~\miniconda3\lib\site-packages\pandas\core\computation\engines.py in evaluate(self)
     78 
     79         # make sure no names in resolvers and locals/globals clash
---> 80         res = self._evaluate()
     81         return reconstruct_object(
     82             self.result_type, res, self.aligned_axes, self.expr.terms.return_type

~\miniconda3\lib\site-packages\pandas\core\computation\engines.py in _evaluate(self)
    118         env = self.expr.env
    119         scope = env.full_scope
--> 120         _check_ne_builtin_clash(self.expr)
    121         return ne.evaluate(s, local_dict=scope)
    122 

~\miniconda3\lib\site-packages\pandas\core\computation\engines.py in _check_ne_builtin_clash(expr)
     34         Terms can contain
     35     """
---> 36     names = expr.names
     37     overlap = names & _ne_builtins
     38 

~\miniconda3\lib\site-packages\pandas\core\computation\expr.py in names(self)
    831         """
    832         if is_term(self.terms):
--> 833             return frozenset([self.terms.name])
    834         return frozenset(term.name for term in com.flatten(self.terms))
    835 

TypeError: unhashable type: 'Series'

Expected Behavior

df.eval("col.str.contains('')" should be the same as df.col.str.contains('')

Installed Versions

INSTALLED VERSIONS ------------------ commit : 5f648bf1706dd75a9ca0d29f26eadfbb595fe52b python : 3.9.6.final.0 python-bits : 64 OS : Windows OS-release : 10 Version : 10.0.19044 machine : AMD64 processor : AMD64 Family 23 Model 96 Stepping 1, AuthenticAMD byteorder : little LC_ALL : None LANG : None LOCALE : Spanish_Mexico.1252 pandas : 1.3.2 numpy : 1.19.2 pytz : 2021.1 dateutil : 2.8.2 pip : 21.2.4 setuptools : 52.0.0.post20210125 Cython : 0.29.28 pytest : None hypothesis : None sphinx : None blosc : None feather : None xlsxwriter : None lxml.etree : None html5lib : None pymysql : None psycopg2 : None jinja2 : 3.0.3 IPython : 7.27.0 pandas_datareader: None bs4 : None bottleneck : 1.3.2 fsspec : None fastparquet : None gcsfs : None matplotlib : 3.4.2 numexpr : 2.7.3 odfpy : None openpyxl : 3.0.9 pandas_gbq : None pyarrow : None pyxlsb : None s3fs : None scipy : 1.6.2 sqlalchemy : None tables : None tabulate : None xarray : None xlrd : None xlwt : None numba : None

Comment From: dannyi96

hi @scratchmex , this seems to be working on master. can you recheck this ? From INSTALLED VERSIONS section, it's mentions pandas : 1.3.2 was used. This issue might have been present in older versions

Comment From: topper-123

This works in master, so I'm closing.