Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

TypeError: 'Series' objects are mutable, thus they cannot be hashed #11

Open
htcml opened this issue Nov 7, 2021 · 1 comment
Open

Comments

@htcml
Copy link

htcml commented Nov 7, 2021

When run benchmark.ipynb, got the following error:


TypeError Traceback (most recent call last)
in
8 pool = mp.Pool(processes=n_process)
9
---> 10 df_splitted = [df.query('u_id.isin(@users_subset)') for users_subset in np.array_split(users, n_process)]
11
12 results = [

in (.0)
8 pool = mp.Pool(processes=n_process)
9
---> 10 df_splitted = [df.query('u_id.isin(@users_subset)') for users_subset in np.array_split(users, n_process)]
11
12 results = [

~/opt/anaconda3/lib/python3.8/site-packages/pandas/core/frame.py in query(self, expr, inplace, **kwargs)
3467 kwargs["level"] = kwargs.pop("level", 0) + 1
3468 kwargs["target"] = None
-> 3469 res = self.eval(expr, **kwargs)
3470
3471 try:

~/opt/anaconda3/lib/python3.8/site-packages/pandas/core/frame.py in eval(self, expr, inplace, **kwargs)
3597 kwargs["resolvers"] = kwargs.get("resolvers", ()) + tuple(resolvers)
3598
-> 3599 return _eval(expr, inplace=inplace, **kwargs)
3600
3601 def select_dtypes(self, include=None, exclude=None) -> DataFrame:

~/opt/anaconda3/lib/python3.8/site-packages/pandas/core/computation/eval.py in eval(expr, parser, engine, truediv, local_dict, global_dict, resolvers, level, target, inplace)
345 eng = ENGINES[engine]
346 eng_inst = eng(parsed_expr)
--> 347 ret = eng_inst.evaluate()
348
349 if parsed_expr.assigner is None:

~/opt/anaconda3/lib/python3.8/site-packages/pandas/core/computation/engines.py in evaluate(self)
71
72 # make sure no names in resolvers and locals/globals clash
---> 73 res = self._evaluate()
74 return reconstruct_object(
75 self.result_type, res, self.aligned_axes, self.expr.terms.return_type

~/opt/anaconda3/lib/python3.8/site-packages/pandas/core/computation/engines.py in _evaluate(self)
111 env = self.expr.env
112 scope = env.full_scope
--> 113 _check_ne_builtin_clash(self.expr)
114 return ne.evaluate(s, local_dict=scope)
115

~/opt/anaconda3/lib/python3.8/site-packages/pandas/core/computation/engines.py in _check_ne_builtin_clash(expr)
27 Terms can contain
28 """
---> 29 names = expr.names
30 overlap = names & _ne_builtins
31

~/opt/anaconda3/lib/python3.8/site-packages/pandas/core/computation/expr.py in names(self)
823 """
824 if is_term(self.terms):
--> 825 return frozenset([self.terms.name])
826 return frozenset(term.name for term in com.flatten(self.terms))
827

~/opt/anaconda3/lib/python3.8/site-packages/pandas/core/generic.py in hash(self)
1783
1784 def hash(self) -> int:
-> 1785 raise TypeError(
1786 f"{repr(type(self).name)} objects are mutable, "
1787 f"thus they cannot be hashed"

TypeError: 'Series' objects are mutable, thus they cannot be hashed

@gbolmier
Copy link
Owner

gbolmier commented Nov 9, 2021

Which pandas version are you using? No problem for me with 1.2.1 and 1.3.4

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants