Skip to content

BUG: maximum recursion depth in eval when using bool object #34044

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

Closed
2 of 3 tasks
wiso opened this issue May 7, 2020 · 5 comments
Closed
2 of 3 tasks

BUG: maximum recursion depth in eval when using bool object #34044

wiso opened this issue May 7, 2020 · 5 comments
Labels
Bug expressions pd.eval, query

Comments

@wiso
Copy link

wiso commented May 7, 2020

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

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

  • (optional) I have confirmed this bug exists on the master branch of pandas.


Code Sample, a copy-pastable example

import pandas as pd
df = pd.DataFrame({"col1": [True] * 50, "col2": [2] * 50})
df["col1"] = df["col1"].astype("object")  
df.eval("col1 & (col2!=2)")

Problem description

RecursionError: maximum recursion depth exceeded while calling a Python object

"col1" in the example is casted to object bool since in my real example I have nan.

Maybe similar to #27639

Output of pd.show_versions()

INSTALLED VERSIONS ------------------ commit : None python : 3.7.6.final.0 python-bits : 64 OS : Linux OS-release : 5.4.15-200.fc31.x86_64 machine : x86_64 processor : x86_64 byteorder : little LC_ALL : None LANG : it_IT.UTF-8 LOCALE : it_IT.UTF-8

pandas : 1.0.3
numpy : 1.18.1
pytz : 2019.2
dateutil : 2.7.5
pip : 20.1
setuptools : 41.6.0
Cython : 0.29.15
pytest : 4.0.0
hypothesis : None
sphinx : None
blosc : None
feather : None
xlsxwriter : None
lxml.etree : 4.4.0
html5lib : 1.0.1
pymysql : None
psycopg2 : None
jinja2 : 2.10
IPython : 7.3.0
pandas_datareader: 0.8.0
bs4 : 4.7.1
bottleneck : 1.2.1
fastparquet : None
gcsfs : None
lxml.etree : 4.4.0
matplotlib : 3.1.3
numexpr : 2.7.1
odfpy : None
openpyxl : None
pandas_gbq : None
pyarrow : None
pytables : None
pytest : 4.0.0
pyxlsb : None
s3fs : 0.4.2
scipy : 1.2.1
sqlalchemy : None
tables : 3.5.2
tabulate : 0.8.5
xarray : 0.12.1
xlrd : 1.2.0
xlwt : 1.1.2
xlsxwriter : None
numba : 0.48.0

@wiso wiso added Bug Needs Triage Issue that has not been reviewed by a pandas team member labels May 7, 2020
@justynatrojniak
Copy link

justynatrojniak commented May 11, 2020

Not sure if this helps but try increase the capacity of the stack by the following :

import sys
sys.setrecursionlimit(10000)

@CloseChoice
Copy link
Member

Nope, that doesnt help. We are calling and recalling the same stuff here. This definitely needs a fix.

@charlesdong1991 charlesdong1991 added expressions pd.eval, query and removed Needs Triage Issue that has not been reviewed by a pandas team member labels May 17, 2020
@stayfools
Copy link

I have the same problem with pandas==1.0.4, and it's about string object:

import pandas as pd
df = pd.DataFrame({'A':list('abc'), 'B':list('def')})
df.eval('A+B')

But it works well with pandas==1.0.1.

@mutricyl
Copy link
Contributor

Could not reproduce the issue with pandas 2.2.0

@wiso
Copy link
Author

wiso commented May 17, 2024

@mutricyl you are correct. It works also with 2.1.3.
By the way I can reproduce with 1.5.3
I am closing this

@wiso wiso closed this as completed May 17, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug expressions pd.eval, query
Projects
None yet
Development

No branches or pull requests

6 participants