Skip to content

Max recursion limit on pd.eval #27639

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

Open
ccharlesgb opened this issue Jul 29, 2019 · 1 comment
Open

Max recursion limit on pd.eval #27639

ccharlesgb opened this issue Jul 29, 2019 · 1 comment
Labels
Bug expressions pd.eval, query

Comments

@ccharlesgb
Copy link
Contributor

Code Sample

After some hypothesis testing on our codebase we noticed that pd.eval can cause a max recursion limit when run on an empty dataframe or an all NaN dataframe:

import pandas as pd
df = pd.DataFrame(index=list(range(0,1)), columns=list('abc'))
df.eval('a*b') # Max recursion limit

And:

import pandas as pd
df = pd.DataFrame(columns=list('abc'))
df.eval('a*b') # Max recursion limit

Interestingly enough using numpy.nan works correctly so the error is caused if the data is native python nan:

import pandas as pd
import numpy as np
df = pd.DataFrame(index=list(range(0,1)), columns=list('abc'), data=np.nan)
df.eval('a*b')

This seems to happen on 0.19.2 so I don't think this is a regression.
A similar issue was raised in 2013 #5198

INSTALLED VERSIONS


commit : None
python : 3.6.5.final.0
python-bits : 64
OS : Windows
OS-release : 7
machine : AMD64
processor : Intel64 Family 6 Model 60 Stepping 3, GenuineIntel
byteorder : little
LC_ALL : None
LANG : None
LOCALE : None.None
pandas : 0.25.0
numpy : 1.16.4
pytz : 2018.4
dateutil : 2.7.3
pip : 10.0.1
setuptools : 39.1.0
Cython : None
pytest : 3.5.1
hypothesis : None
sphinx : 1.8.2
blosc : None
feather : None
xlsxwriter : 1.0.4
lxml.etree : 4.1.1
html5lib : 1.0.1
pymysql : None
psycopg2 : None
jinja2 : 2.10
IPython : 6.4.0
pandas_datareader: None
bs4 : 4.7.1
bottleneck : None
fastparquet : None
gcsfs : None
lxml.etree : 4.1.1
matplotlib : 2.2.2
numexpr : 2.6.5
odfpy : None
openpyxl : None
pandas_gbq : None
pyarrow : None
pytables : None
s3fs : None
scipy : 1.1.0
sqlalchemy : 1.2.8
tables : 3.5.2
xarray : None
xlrd : 1.1.0
xlwt : None
xlsxwriter : 1.0.4

@mutricyl
Copy link
Contributor

could not reproduce this issue with pandas 2.2.0

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

4 participants