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

dataframe.query must rely on 'python' engine to deal with NaN-related queries #116

Closed
VinceBaz opened this issue Oct 8, 2019 · 1 comment · Fixed by #117
Closed

dataframe.query must rely on 'python' engine to deal with NaN-related queries #116

VinceBaz opened this issue Oct 8, 2019 · 1 comment · Fixed by #117
Labels
bug Something isn't working

Comments

@VinceBaz
Copy link
Contributor

VinceBaz commented Oct 8, 2019

It turns out that the 'numexpr' engine, which is used by default by pandas.eval cannot handle pd.Series for an unknown reason -> https://stackoverflow.com/questions/51878316/pandas-python-series-objects-are-mutable-thus-they-cannot-be-hashed-in-query-me.

When a user doesn't have the 'numexpr' engine installed on his computer, everything is fine, because in that case pandas.eval will use the 'python' engine instead, but otherwise, the following line of code

annot = annot.assign(hemisphere=hemisphere, structure=structure) \
                       .query('(hemisphere == "L" & mni_x < 0) '
                        '| (hemisphere == "R" & mni_x > 0) '
                        '| (hemisphere.isna() & mni_x == 0)')

will raise the following error

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

@rmarkello rmarkello added the bug Something isn't working label Oct 9, 2019
@rmarkello
Copy link
Owner

Great! Seems like the solution is just add engine='python' to the end of the .query() call. If you're interested in submitting a PR for this that would be great! Let me know if you're up for it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants